<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name=Generator content="Microsoft Word 14 (filtered)">

<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:宋体;
	panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
	{font-family:黑体;
	panose-1:2 1 6 9 6 1 1 1 1 1;}
@font-face
	{font-family:黑体;
	panose-1:2 1 6 9 6 1 1 1 1 1;}
@font-face
	{font-family:方正小标宋简体;}
@font-face
	{font-family:"\@黑体";
	panose-1:2 1 6 9 6 1 1 1 1 1;}
@font-face
	{font-family:"\@宋体";
	panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
	{font-family:"\@方正小标宋简体";}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;}
h1
	{mso-style-link:"标题 1 Char";
	margin-top:17.0pt;
	margin-right:0cm;
	margin-bottom:16.5pt;
	margin-left:7.2pt;
	text-align:center;
	text-indent:-7.2pt;
	page-break-after:avoid;
	font-size:22.0pt;
	font-family:宋体;
	font-weight:bold;}
h2
	{mso-style-link:"标题 2 Char";
	margin-top:13.0pt;
	margin-right:0cm;
	margin-bottom:13.0pt;
	margin-left:0cm;
	text-align:justify;
	text-justify:inter-ideograph;
	text-indent:0cm;
	page-break-after:avoid;
	font-size:16.0pt;
	font-family:"Arial","sans-serif";
	font-weight:bold;}
h3
	{mso-style-link:"标题 3 Char";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	text-indent:0cm;
	page-break-after:avoid;
	font-size:14.0pt;
	font-family:"Arial","sans-serif";
	font-weight:bold;}
h4
	{mso-style-link:"标题 4 Char";
	margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:28.8pt;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	text-indent:-28.8pt;
	page-break-after:avoid;
	font-size:12.0pt;
	font-family:"Arial","sans-serif";
	font-weight:bold;}
h5
	{mso-style-link:"标题 5 Char";
	margin-top:14.0pt;
	margin-right:0cm;
	margin-bottom:14.5pt;
	margin-left:36.0pt;
	text-align:justify;
	text-justify:inter-ideograph;
	text-indent:-36.0pt;
	line-height:156%;
	page-break-after:avoid;
	font-size:14.0pt;
	font-family:宋体;
	font-weight:bold;}
h6
	{mso-style-link:"标题 6 Char";
	margin-top:12.0pt;
	margin-right:0cm;
	margin-bottom:3.2pt;
	margin-left:43.2pt;
	text-align:justify;
	text-justify:inter-ideograph;
	text-indent:-43.2pt;
	line-height:133%;
	page-break-after:avoid;
	font-size:12.0pt;
	font-family:"Arial","sans-serif";
	font-weight:bold;}
p.MsoHeading7, li.MsoHeading7, div.MsoHeading7
	{mso-style-link:"标题 7 Char";
	margin-top:12.0pt;
	margin-right:0cm;
	margin-bottom:3.2pt;
	margin-left:50.4pt;
	text-align:justify;
	text-justify:inter-ideograph;
	text-indent:-50.4pt;
	line-height:133%;
	page-break-after:avoid;
	font-size:12.0pt;
	font-family:宋体;
	font-weight:bold;}
p.MsoHeading8, li.MsoHeading8, div.MsoHeading8
	{mso-style-link:"标题 8 Char";
	margin-top:12.0pt;
	margin-right:0cm;
	margin-bottom:3.2pt;
	margin-left:57.6pt;
	text-align:justify;
	text-justify:inter-ideograph;
	text-indent:-72.0pt;
	line-height:133%;
	page-break-after:avoid;
	font-size:12.0pt;
	font-family:"Arial","sans-serif";}
p.MsoHeading9, li.MsoHeading9, div.MsoHeading9
	{mso-style-link:"标题 9 Char";
	margin-top:12.0pt;
	margin-right:0cm;
	margin-bottom:3.2pt;
	margin-left:64.8pt;
	text-align:justify;
	text-justify:inter-ideograph;
	text-indent:-79.2pt;
	line-height:133%;
	page-break-after:avoid;
	font-size:10.5pt;
	font-family:"Arial","sans-serif";}
p.MsoIndex1, li.MsoIndex1, div.MsoIndex1
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:10.5pt;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	text-indent:-10.5pt;
	font-size:10.5pt;
	font-family:宋体;}
p.MsoIndex2, li.MsoIndex2, div.MsoIndex2
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:21.0pt;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	text-indent:-10.5pt;
	font-size:10.5pt;
	font-family:宋体;}
p.MsoIndex3, li.MsoIndex3, div.MsoIndex3
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:31.5pt;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	text-indent:-10.5pt;
	font-size:10.5pt;
	font-family:宋体;}
p.MsoIndex4, li.MsoIndex4, div.MsoIndex4
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:42.0pt;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	text-indent:-10.5pt;
	font-size:10.5pt;
	font-family:宋体;}
p.MsoIndex5, li.MsoIndex5, div.MsoIndex5
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:52.5pt;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	text-indent:-10.5pt;
	font-size:10.5pt;
	font-family:宋体;}
p.MsoIndex6, li.MsoIndex6, div.MsoIndex6
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:63.0pt;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	text-indent:-10.5pt;
	font-size:10.5pt;
	font-family:宋体;}
p.MsoIndex7, li.MsoIndex7, div.MsoIndex7
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:73.5pt;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	text-indent:-10.5pt;
	font-size:10.5pt;
	font-family:宋体;}
p.MsoIndex8, li.MsoIndex8, div.MsoIndex8
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:84.0pt;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	text-indent:-10.5pt;
	font-size:10.5pt;
	font-family:宋体;}
p.MsoIndex9, li.MsoIndex9, div.MsoIndex9
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:94.5pt;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	text-indent:-10.5pt;
	font-size:10.5pt;
	font-family:宋体;}
p.MsoToc1, li.MsoToc1, div.MsoToc1
	{margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;
	font-weight:bold;}
p.MsoToc2, li.MsoToc2, div.MsoToc2
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:21.0pt;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;}
p.MsoToc3, li.MsoToc3, div.MsoToc3
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:42.0pt;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;}
p.MsoToc4, li.MsoToc4, div.MsoToc4
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:31.5pt;
	margin-bottom:.0001pt;
	font-size:9.0pt;
	font-family:宋体;}
p.MsoToc5, li.MsoToc5, div.MsoToc5
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:42.0pt;
	margin-bottom:.0001pt;
	font-size:9.0pt;
	font-family:宋体;}
p.MsoToc6, li.MsoToc6, div.MsoToc6
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:52.5pt;
	margin-bottom:.0001pt;
	font-size:9.0pt;
	font-family:宋体;}
p.MsoToc7, li.MsoToc7, div.MsoToc7
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:63.0pt;
	margin-bottom:.0001pt;
	font-size:9.0pt;
	font-family:宋体;}
p.MsoToc8, li.MsoToc8, div.MsoToc8
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:73.5pt;
	margin-bottom:.0001pt;
	font-size:9.0pt;
	font-family:宋体;}
p.MsoToc9, li.MsoToc9, div.MsoToc9
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:84.0pt;
	margin-bottom:.0001pt;
	font-size:9.0pt;
	font-family:宋体;}
p.MsoFootnoteText, li.MsoFootnoteText, div.MsoFootnoteText
	{mso-style-link:"脚注文本 Char";
	margin:0cm;
	margin-bottom:.0001pt;
	layout-grid-mode:char;
	font-size:9.0pt;
	font-family:宋体;}
p.MsoCommentText, li.MsoCommentText, div.MsoCommentText
	{mso-style-link:"批注文字 Char";
	margin:0cm;
	margin-bottom:.0001pt;
	font-size:10.5pt;
	font-family:宋体;}
p.MsoHeader, li.MsoHeader, div.MsoHeader
	{mso-style-link:"页眉 Char";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	layout-grid-mode:char;
	border:none;
	padding:0cm;
	font-size:9.0pt;
	font-family:宋体;}
p.MsoFooter, li.MsoFooter, div.MsoFooter
	{mso-style-link:"页脚 Char";
	margin:0cm;
	margin-bottom:.0001pt;
	layout-grid-mode:char;
	font-size:9.0pt;
	font-family:宋体;}
p.MsoIndexHeading, li.MsoIndexHeading, div.MsoIndexHeading
	{mso-style-name:"索引标题\,索引类目\,索引类目1\,索引类目2";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;}
p.MsoCaption, li.MsoCaption, div.MsoCaption
	{margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:"Arial","sans-serif";}
p.MsoTof, li.MsoTof, div.MsoTof
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:42.0pt;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	text-indent:-21.0pt;
	font-size:10.5pt;
	font-family:宋体;}
span.MsoFootnoteReference
	{vertical-align:super;}
p.MsoList, li.MsoList, div.MsoList
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:21.0pt;
	margin-bottom:.0001pt;
	text-align:center;
	text-indent:-21.0pt;
	font-size:10.5pt;
	font-family:宋体;}
p.MsoList2, li.MsoList2, div.MsoList2
	{margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;}
p.MsoList4, li.MsoList4, div.MsoList4
	{margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.MsoDate, li.MsoDate, div.MsoDate
	{mso-style-link:"日期 Char";
	margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:5.0pt;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;}
a:link, span.MsoHyperlink
	{mso-style-name:"超链接\,超级链接";
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;}
p
	{mso-style-name:"普通\(网站\)\,普通 \(Web\)\,普通 \(Web\)1\,普通 \(Web\)2\,普通 \(Web\)3";
	margin-right:0cm;
	margin-left:0cm;
	font-size:12.0pt;
	font-family:宋体;}
pre
	{mso-style-name:"HTML 预设格式\,HTML 预先格式化\,HTML 预先格式化1\,HTML 预先格式化2\,HTML 预先格式化3";
	mso-style-link:"HTML 预设格式 Char\,HTML 预先格式化 Char\,HTML 预先格式化1 Char\,HTML 预先格式化2 Char\,HTML 预先格式化3 Char";
	margin:0cm;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:宋体;}
tt
	{font-family:黑体;}
p.MsoCommentSubject, li.MsoCommentSubject, div.MsoCommentSubject
	{mso-style-link:"批注主题 Char";
	margin:0cm;
	margin-bottom:.0001pt;
	font-size:10.5pt;
	font-family:宋体;
	font-weight:bold;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
	{mso-style-link:"批注框文本 Char";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:9.0pt;
	font-family:宋体;}
p.1, li.1, div.1
	{mso-style-name:样式1;
	margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:21.0pt;
	margin-bottom:.0001pt;
	text-align:center;
	text-indent:-21.0pt;
	font-size:10.5pt;
	font-family:宋体;}
p.a, li.a, div.a
	{mso-style-name:代码程序;
	mso-style-link:"代码程序 Char";
	margin:0cm;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:宋体;}
span.Char
	{mso-style-name:"代码程序 Char";
	mso-style-link:代码程序;
	font-family:宋体;}
p.a0, li.a0, div.a0
	{mso-style-name:图说明;
	mso-style-link:"图说明 Char";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
span.Char0
	{mso-style-name:"图说明 Char";
	mso-style-link:图说明;
	font-family:宋体;}
p.0, li.0, div.0
	{mso-style-name:封面0;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:36.0pt;
	font-family:宋体;
	font-weight:bold;}
p.10, li.10, div.10
	{mso-style-name:封面1;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:18.0pt;
	font-family:宋体;
	font-weight:bold;}
p.11, li.11, div.11
	{mso-style-name:非标题1;
	margin-top:7.8pt;
	margin-right:0cm;
	margin-bottom:7.8pt;
	margin-left:0cm;
	text-align:center;
	font-size:22.0pt;
	font-family:宋体;
	font-weight:bold;}
p.a1, li.a1, div.a1
	{mso-style-name:文本居中;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.3CharChar, li.3CharChar, div.3CharChar
	{mso-style-name:"图中文字3 Char Char";
	mso-style-link:"图中文字3 Char Char Char";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	line-height:9.0pt;
	font-size:8.0pt;
	font-family:宋体;}
span.3CharCharChar
	{mso-style-name:"图中文字3 Char Char Char";
	mso-style-link:"图中文字3 Char Char";
	font-family:宋体;}
p.post, li.post, div.post
	{mso-style-name:邮件post;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:right;
	line-height:11.0pt;
	font-size:10.5pt;
	font-family:宋体;}
p.3, li.3, div.3
	{mso-style-name:图中字体3;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;}
span.3CharChar1CharCharChar
	{mso-style-name:"图中文字3 Char Char1 Char Char Char";
	font-family:宋体;}
span.3CharChar1CharChar
	{mso-style-name:"图中文字3 Char Char1 Char Char";
	font-family:宋体;}
p.5Char, li.5Char, div.5Char
	{mso-style-name:"图中文字5号 Char";
	mso-style-link:"图中文字5号 Char Char";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
span.5CharChar
	{mso-style-name:"图中文字5号 Char Char";
	mso-style-link:"图中文字5号 Char";
	font-family:宋体;}
p.5CharChar0, li.5CharChar0, div.5CharChar0
	{mso-style-name:"图中文字小5号 Char Char";
	mso-style-link:"图中文字小5号 Char Char Char";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:9.0pt;
	font-family:宋体;}
span.5CharCharChar
	{mso-style-name:"图中文字小5号 Char Char Char";
	mso-style-link:"图中文字小5号 Char Char";
	font-family:宋体;}
p.5Char0, li.5Char0, div.5Char0
	{mso-style-name:"图中文字小5号 Char";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:9.0pt;
	font-family:宋体;}
p.5, li.5, div.5
	{mso-style-name:图中文字小5号;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	layout-grid-mode:char;
	font-size:9.0pt;
	font-family:宋体;}
p.2, li.2, div.2
	{mso-style-name:代码程序2;
	margin:0cm;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:宋体;}
p.20, li.20, div.20
	{mso-style-name:图说明2;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.21, li.21, div.21
	{mso-style-name:文本居中2;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.3CharCharCharCharChar, li.3CharCharCharCharChar, div.3CharCharCharCharChar
	{mso-style-name:"图中文字3 Char Char Char Char Char";
	mso-style-link:"图中文字3 Char Char Char Char Char Char";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	line-height:9.0pt;
	font-size:8.0pt;
	font-family:宋体;}
span.3CharCharCharCharCharChar
	{mso-style-name:"图中文字3 Char Char Char Char Char Char";
	mso-style-link:"图中文字3 Char Char Char Char Char";
	font-family:宋体;}
p.a2, li.a2, div.a2
	{mso-style-name:图居中;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.110, li.110, div.110
	{mso-style-name:"样式 标题 1 + 居中1";
	margin-right:0cm;
	margin-left:0cm;
	text-align:center;
	page-break-after:avoid;
	font-size:22.0pt;
	font-family:宋体;
	font-weight:bold;}
span.1Char
	{mso-style-name:"标题 1 Char";
	mso-style-link:"标题 1";
	font-weight:bold;}
p.22, li.22, div.22
	{mso-style-name:"样式 列表 2 + 居中";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.23, li.23, div.23
	{mso-style-name:列表2;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.50, li.50, div.50
	{mso-style-name:图中文字5号;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.111, li.111, div.111
	{mso-style-name:样式11;
	margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:21.0pt;
	margin-bottom:.0001pt;
	text-align:center;
	text-indent:-21.0pt;
	font-size:10.5pt;
	font-family:宋体;}
p.12, li.12, div.12
	{mso-style-name:代码程序1;
	margin:0cm;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:宋体;}
p.13, li.13, div.13
	{mso-style-name:图说明1;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.01, li.01, div.01
	{mso-style-name:封面01;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:36.0pt;
	font-family:宋体;
	font-weight:bold;}
p.112, li.112, div.112
	{mso-style-name:封面11;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:18.0pt;
	font-family:宋体;
	font-weight:bold;}
p.113, li.113, div.113
	{mso-style-name:非标题11;
	margin-top:7.8pt;
	margin-right:0cm;
	margin-bottom:7.8pt;
	margin-left:0cm;
	text-align:center;
	font-size:22.0pt;
	font-family:宋体;
	font-weight:bold;}
p.14, li.14, div.14
	{mso-style-name:文本居中1;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.3Char1, li.3Char1, div.3Char1
	{mso-style-name:"图中文字3 Char1";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	line-height:9.0pt;
	font-size:8.0pt;
	font-family:宋体;}
p.post1, li.post1, div.post1
	{mso-style-name:邮件post1;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:right;
	line-height:11.0pt;
	font-size:10.5pt;
	font-family:宋体;}
p.31, li.31, div.31
	{mso-style-name:图中字体31;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;}
p.5Char1, li.5Char1, div.5Char1
	{mso-style-name:"图中文字5号 Char1";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.5CharChar1, li.5CharChar1, div.5CharChar1
	{mso-style-name:"图中文字小5号 Char Char1";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:9.0pt;
	font-family:宋体;}
p.5Char10, li.5Char10, div.5Char10
	{mso-style-name:"图中文字小5号 Char1";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:9.0pt;
	font-family:宋体;}
p.51, li.51, div.51
	{mso-style-name:图中文字小5号1;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:9.0pt;
	font-family:宋体;}
p.120, li.120, div.120
	{mso-style-name:样式12;
	margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:21.0pt;
	margin-bottom:.0001pt;
	text-align:center;
	text-indent:-21.0pt;
	font-size:10.5pt;
	font-family:宋体;}
p.02, li.02, div.02
	{mso-style-name:封面02;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:36.0pt;
	font-family:宋体;
	font-weight:bold;}
p.121, li.121, div.121
	{mso-style-name:封面12;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:18.0pt;
	font-family:宋体;
	font-weight:bold;}
p.122, li.122, div.122
	{mso-style-name:非标题12;
	margin-top:7.8pt;
	margin-right:0cm;
	margin-bottom:7.8pt;
	margin-left:0cm;
	text-align:center;
	font-size:22.0pt;
	font-family:宋体;
	font-weight:bold;}
p.3Char2, li.3Char2, div.3Char2
	{mso-style-name:"图中文字3 Char2";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	line-height:9.0pt;
	font-size:8.0pt;
	font-family:宋体;}
p.post2, li.post2, div.post2
	{mso-style-name:邮件post2;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:right;
	line-height:11.0pt;
	font-size:10.5pt;
	font-family:宋体;}
p.32, li.32, div.32
	{mso-style-name:图中字体32;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;}
p.5Char2, li.5Char2, div.5Char2
	{mso-style-name:"图中文字小5号 Char2";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:9.0pt;
	font-family:宋体;}
p.52, li.52, div.52
	{mso-style-name:图中文字小5号2;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:9.0pt;
	font-family:宋体;}
p.3CharCharCharChar, li.3CharCharCharChar, div.3CharCharCharChar
	{mso-style-name:"图中文字3 Char Char Char Char";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	line-height:9.0pt;
	font-size:8.0pt;
	font-family:宋体;}
p.130, li.130, div.130
	{mso-style-name:样式13;
	margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:21.0pt;
	margin-bottom:.0001pt;
	text-align:center;
	text-indent:-21.0pt;
	font-size:10.5pt;
	font-family:宋体;}
p.30, li.30, div.30
	{mso-style-name:代码程序3;
	margin:0cm;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:宋体;}
p.03, li.03, div.03
	{mso-style-name:封面03;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:36.0pt;
	font-family:宋体;
	font-weight:bold;}
p.131, li.131, div.131
	{mso-style-name:封面13;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:18.0pt;
	font-family:宋体;
	font-weight:bold;}
p.132, li.132, div.132
	{mso-style-name:非标题13;
	margin-top:7.8pt;
	margin-right:0cm;
	margin-bottom:7.8pt;
	margin-left:0cm;
	text-align:center;
	font-size:22.0pt;
	font-family:宋体;
	font-weight:bold;}
p.33, li.33, div.33
	{mso-style-name:文本居中3;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.3Char3, li.3Char3, div.3Char3
	{mso-style-name:"图中文字3 Char3";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	line-height:9.0pt;
	font-size:8.0pt;
	font-family:宋体;}
p.post3, li.post3, div.post3
	{mso-style-name:邮件post3;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:right;
	line-height:11.0pt;
	font-size:10.5pt;
	font-family:宋体;}
p.330, li.330, div.330
	{mso-style-name:图中字体33;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;}
p.5Char20, li.5Char20, div.5Char20
	{mso-style-name:"图中文字5号 Char2";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.5CharChar2, li.5CharChar2, div.5CharChar2
	{mso-style-name:"图中文字小5号 Char Char2";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:9.0pt;
	font-family:宋体;}
p.5Char3, li.5Char3, div.5Char3
	{mso-style-name:"图中文字小5号 Char3";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:9.0pt;
	font-family:宋体;}
p.53, li.53, div.53
	{mso-style-name:图中文字小5号3;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:9.0pt;
	font-family:宋体;}
p.3Char, li.3Char, div.3Char
	{mso-style-name:"图中文字3 Char";
	mso-style-link:"图中文字3 Char Char5";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	line-height:9.0pt;
	font-size:8.0pt;
	font-family:宋体;}
span.3CharChar5
	{mso-style-name:"图中文字3 Char Char5";
	mso-style-link:"图中文字3 Char";
	font-family:宋体;}
p.54, li.54, div.54
	{mso-style-name:图中文字小5紧密;
	margin:0cm;
	margin-bottom:.0001pt;
	line-height:9.0pt;
	text-autospace:ideograph-numeric;
	font-size:9.0pt;
	font-family:宋体;}
p.24, li.24, div.24
	{mso-style-name:居中2号粗宋体;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:22.0pt;
	font-family:宋体;
	font-weight:bold;}
p.15, li.15, div.15
	{mso-style-name:"样式 标题 1 + 居中";
	margin-top:17.0pt;
	margin-right:0cm;
	margin-bottom:16.5pt;
	margin-left:0cm;
	text-align:center;
	page-break-after:avoid;
	font-size:22.0pt;
	font-family:宋体;
	font-weight:bold;}
p.25, li.25, div.25
	{mso-style-name:"样式 标题 2 + 行距\: 单倍行距";
	margin-top:13.0pt;
	margin-right:0cm;
	margin-bottom:13.0pt;
	margin-left:28.9pt;
	text-align:justify;
	text-justify:inter-ideograph;
	text-indent:-28.9pt;
	page-break-after:avoid;
	font-size:16.0pt;
	font-family:"Arial","sans-serif";
	font-weight:bold;}
span.2Char
	{mso-style-name:"标题 2 Char";
	mso-style-link:"标题 2";
	font-family:"Arial","sans-serif";
	font-weight:bold;}
p.34, li.34, div.34
	{mso-style-name:列表3;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.35, li.35, div.35
	{mso-style-name:表3;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.4, li.4, div.4
	{mso-style-name:图说明4;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.40, li.40, div.40
	{mso-style-name:列表4;
	margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:21.0pt;
	margin-bottom:.0001pt;
	text-align:center;
	text-indent:-21.0pt;
	font-size:10.5pt;
	font-family:宋体;}
p.41, li.41, div.41
	{mso-style-name:表4;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.55, li.55, div.55
	{mso-style-name:图说明5;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.56, li.56, div.56
	{mso-style-name:列表5;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.57, li.57, div.57
	{mso-style-name:表5;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.6, li.6, div.6
	{mso-style-name:列表6;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.60, li.60, div.60
	{mso-style-name:表6;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.61, li.61, div.61
	{mso-style-name:图说明6;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.7, li.7, div.7
	{mso-style-name:列表7;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.70, li.70, div.70
	{mso-style-name:图说明7;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.71, li.71, div.71
	{mso-style-name:表7;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.8, li.8, div.8
	{mso-style-name:列表8;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.9, li.9, div.9
	{mso-style-name:列表9;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.90, li.90, div.90
	{mso-style-name:图说明9;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.100, li.100, div.100
	{mso-style-name:列表10;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.101, li.101, div.101
	{mso-style-name:图说明10;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.114, li.114, div.114
	{mso-style-name:列表11;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.115, li.115, div.115
	{mso-style-name:图说明11;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.116, li.116, div.116
	{mso-style-name:表11;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.123, li.123, div.123
	{mso-style-name:列表12;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.124, li.124, div.124
	{mso-style-name:图说明12;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.133, li.133, div.133
	{mso-style-name:图说明13;
	mso-style-link:"图说明13 Char";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
span.13Char
	{mso-style-name:"图说明13 Char";
	mso-style-link:图说明13;
	font-family:宋体;}
p.134, li.134, div.134
	{mso-style-name:列表13;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.26, li.26, div.26
	{mso-style-name:附录2;
	margin-top:13.0pt;
	margin-right:0cm;
	margin-bottom:13.0pt;
	margin-left:0cm;
	text-align:justify;
	text-justify:inter-ideograph;
	page-break-after:avoid;
	font-size:16.0pt;
	font-family:"Arial","sans-serif";
	font-weight:bold;}
p.36, li.36, div.36
	{mso-style-name:附录3;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	page-break-after:avoid;
	font-size:14.0pt;
	font-family:"Arial","sans-serif";
	font-weight:bold;}
span.3Char0
	{mso-style-name:"标题 3 Char";
	mso-style-link:"标题 3";
	font-family:"Arial","sans-serif";
	font-weight:bold;}
p.16, li.16, div.16
	{mso-style-name:附录1;
	margin-top:17.0pt;
	margin-right:0cm;
	margin-bottom:16.5pt;
	margin-left:0cm;
	text-align:center;
	page-break-after:avoid;
	font-size:22.0pt;
	font-family:宋体;
	font-weight:bold;}
p.17, li.17, div.17
	{mso-style-name:附录表1;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.42, li.42, div.42
	{mso-style-name:附录4;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	page-break-after:avoid;
	font-size:12.0pt;
	font-family:"Arial","sans-serif";
	font-weight:bold;}
span.4Char
	{mso-style-name:"标题 4 Char";
	mso-style-link:"标题 4";
	font-family:"Arial","sans-serif";
	font-weight:bold;}
p.a3, li.a3, div.a3
	{mso-style-name:附录图说明;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.27, li.27, div.27
	{mso-style-name:序标题2;
	margin-top:13.0pt;
	margin-right:0cm;
	margin-bottom:13.0pt;
	margin-left:28.8pt;
	text-align:justify;
	text-justify:inter-ideograph;
	text-indent:-28.8pt;
	page-break-after:avoid;
	font-size:16.0pt;
	font-family:"Arial","sans-serif";
	font-weight:bold;}
p.a4, li.a4, div.a4
	{mso-style-name:参考标题;
	margin-top:7.8pt;
	margin-right:0cm;
	margin-bottom:7.8pt;
	margin-left:0cm;
	text-align:center;
	page-break-after:avoid;
	font-size:22.0pt;
	font-family:宋体;
	font-weight:bold;}
p.18, li.18, div.18
	{mso-style-name:索引标题1;
	margin-top:7.8pt;
	margin-right:0cm;
	margin-bottom:7.8pt;
	margin-left:0cm;
	text-align:center;
	page-break-after:avoid;
	font-size:22.0pt;
	font-family:宋体;
	font-weight:bold;}
p.19, li.19, div.19
	{mso-style-name:列表1;
	margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:21.25pt;
	margin-bottom:.0001pt;
	text-align:center;
	text-indent:-21.25pt;
	font-size:10.5pt;
	font-family:宋体;}
p.1a, li.1a, div.1a
	{mso-style-name:表1;
	margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:21.25pt;
	margin-bottom:.0001pt;
	text-align:center;
	text-indent:-21.25pt;
	font-size:10.5pt;
	font-family:宋体;}
p.37, li.37, div.37
	{mso-style-name:图说明3;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.62, li.62, div.62
	{mso-style-name:表中字体6号;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	layout-grid-mode:char;
	font-size:7.5pt;
	font-family:宋体;}
p.a5, li.a5, div.a5
	{mso-style-name:正文代码;
	mso-style-link:"正文代码 Char";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;}
span.Char1
	{mso-style-name:"正文代码 Char";
	mso-style-link:正文代码;
	font-family:宋体;}
p.43, li.43, div.43
	{mso-style-name:"样式 标题 4 +";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	page-break-after:avoid;
	font-size:12.0pt;
	font-family:"Arial","sans-serif";
	font-weight:bold;}
p.140, li.140, div.140
	{mso-style-name:表14;
	margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:21.25pt;
	margin-bottom:.0001pt;
	text-align:center;
	text-indent:-21.25pt;
	font-size:10.5pt;
	font-family:宋体;}
p.141, li.141, div.141
	{mso-style-name:图说明14;
	mso-style-link:"图说明14 Char";
	margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:21.25pt;
	margin-bottom:.0001pt;
	text-align:center;
	text-indent:-21.25pt;
	font-size:10.5pt;
	font-family:宋体;}
span.14Char
	{mso-style-name:"图说明14 Char";
	mso-style-link:图说明14;
	font-family:宋体;}
p.a6, li.a6, div.a6
	{mso-style-name:文件目录表;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;}
p.a7, li.a7, div.a7
	{mso-style-name:"样式 正文 +";
	mso-style-link:"样式 正文 + Char";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;}
span.Char2
	{mso-style-name:"样式 正文 + Char";
	mso-style-link:"样式 正文 +";
	font-family:"Times New Roman","serif";}
p.a8, li.a8, div.a8
	{mso-style-name:表格题注;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.a9, li.a9, div.a9
	{mso-style-name:列表题注;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:"Arial","sans-serif";}
p.aa, li.aa, div.aa
	{mso-style-name:图题注;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:"Arial","sans-serif";}
p.ab, li.ab, div.ab
	{mso-style-name:程序题注;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:"Arial","sans-serif";}
p.ac, li.ac, div.ac
	{mso-style-name:框中文字;
	margin-top:0cm;
	margin-right:21.0pt;
	margin-bottom:0cm;
	margin-left:21.0pt;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	border:none;
	padding:0cm;
	font-size:9.0pt;
	font-family:宋体;}
p.125, li.125, div.125
	{mso-style-name:"样式 标题 1 + 居中2";
	margin-top:17.0pt;
	margin-right:0cm;
	margin-bottom:16.5pt;
	margin-left:0cm;
	text-align:center;
	page-break-after:avoid;
	font-size:22.0pt;
	font-family:宋体;
	font-weight:bold;}
p.ad, li.ad, div.ad
	{mso-style-name:"样式 题注 + 宋体 五号 居中";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:黑体;}
p.1b, li.1b, div.1b
	{mso-style-name:序标题1;
	margin-top:17.0pt;
	margin-right:0cm;
	margin-bottom:16.5pt;
	margin-left:0cm;
	line-height:240%;
	page-break-after:avoid;
	font-size:16.0pt;
	font-family:宋体;
	font-weight:bold;}
p.38, li.38, div.38
	{mso-style-name:序标题3;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	page-break-after:avoid;
	font-size:12.0pt;
	font-family:方正小标宋简体;}
p.63, li.63, div.63
	{mso-style-name:表中文字6号;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:7.5pt;
	font-family:宋体;}
p.64, li.64, div.64
	{mso-style-name:图中文字6号左对齐;
	margin:0cm;
	margin-bottom:.0001pt;
	line-height:10.0pt;
	layout-grid-mode:char;
	font-size:7.5pt;
	font-family:宋体;}
p.65, li.65, div.65
	{mso-style-name:图中文字6号;
	mso-style-link:"图中文字6号 Char";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	line-height:10.0pt;
	layout-grid-mode:char;
	font-size:7.5pt;
	font-family:宋体;}
span.6Char
	{mso-style-name:"图中文字6号 Char";
	mso-style-link:图中文字6号;
	font-family:宋体;}
p.ae, li.ae, div.ae
	{mso-style-name:图标;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;}
p.28, li.28, div.28
	{mso-style-name:图标2;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;}
p.af, li.af, div.af
	{mso-style-name:习题标题;
	margin-top:6.0pt;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	page-break-after:avoid;
	font-size:14.0pt;
	font-family:黑体;}
p.1c, li.1c, div.1c
	{mso-style-name:部分编号1;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:16.0pt;
	font-family:宋体;}
p.af0, li.af0, div.af0
	{mso-style-name:表标题;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:"Arial","sans-serif";}
p.af1, li.af1, div.af1
	{mso-style-name:"样式 题注 + 居中";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:宋体;}
p.ListTitle, li.ListTitle, div.ListTitle
	{mso-style-name:ListTitle;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:"Arial","sans-serif";}
p.FigureTitle, li.FigureTitle, div.FigureTitle
	{mso-style-name:FigureTitle;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:"Arial","sans-serif";}
p.TableTitle, li.TableTitle, div.TableTitle
	{mso-style-name:TableTitle;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:"Arial","sans-serif";}
p.ProgramTitle, li.ProgramTitle, div.ProgramTitle
	{mso-style-name:ProgramTitle;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.5pt;
	font-family:"Arial","sans-serif";}
p.RightText, li.RightText, div.RightText
	{mso-style-name:RightText;
	margin-top:0cm;
	margin-right:21.0pt;
	margin-bottom:0cm;
	margin-left:42.0pt;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	border:none;
	padding:0cm;
	font-size:9.0pt;
	font-family:宋体;}
p.af2, li.af2, div.af2
	{mso-style-name:表中文字小五;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:9.0pt;
	font-family:宋体;}
p.af3, li.af3, div.af3
	{mso-style-name:关键词;
	mso-style-link:"关键词 Char";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;}
span.Char3
	{mso-style-name:"关键词 Char";
	mso-style-link:关键词;
	font-family:宋体;}
p.af4, li.af4, div.af4
	{mso-style-name:文件名;
	mso-style-link:"文件名 Char";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;}
span.Char4
	{mso-style-name:"文件名 Char";
	mso-style-link:文件名;
	font-family:宋体;}
p.af5, li.af5, div.af5
	{mso-style-name:选项;
	mso-style-link:"选项 Char";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;}
span.Char5
	{mso-style-name:"选项 Char";
	mso-style-link:选项;
	font-family:宋体;}
p.af6, li.af6, div.af6
	{mso-style-name:命令行;
	mso-style-link:"命令行 Char";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;}
span.Char6
	{mso-style-name:"命令行 Char";
	mso-style-link:命令行;
	font-family:宋体;}
p.af7, li.af7, div.af7
	{mso-style-name:函数名;
	mso-style-link:"函数名 Char";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;}
span.Char7
	{mso-style-name:"函数名 Char";
	mso-style-link:函数名;
	font-family:宋体;}
p.af8, li.af8, div.af8
	{mso-style-name:寄存器名;
	mso-style-link:"寄存器名 Char";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;}
span.Char8
	{mso-style-name:"寄存器名 Char";
	mso-style-link:寄存器名;
	font-family:"Times New Roman","serif";}
p.af9, li.af9, div.af9
	{mso-style-name:变量名;
	mso-style-link:"变量名 Char";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:宋体;}
span.Char9
	{mso-style-name:"变量名 Char";
	mso-style-link:变量名;
	font-family:宋体;}
p.58, li.58, div.58
	{mso-style-name:图中文字小5号左;
	margin:0cm;
	margin-bottom:.0001pt;
	font-size:9.0pt;
	font-family:宋体;}
p.59, li.59, div.59
	{mso-style-name:图中文字小5号靠左;
	margin:0cm;
	margin-bottom:.0001pt;
	layout-grid-mode:char;
	font-size:9.0pt;
	font-family:宋体;}
p.926, li.926, div.926
	{mso-style-name:"样式 代码程序 + 左侧\:  9\.26 厘米";
	margin:0cm;
	margin-bottom:.0001pt;
	layout-grid-mode:char;
	font-size:10.0pt;
	font-family:宋体;}
span.5Char4
	{mso-style-name:"标题 5 Char";
	mso-style-link:"标题 5";
	font-weight:bold;}
span.6Char0
	{mso-style-name:"标题 6 Char";
	mso-style-link:"标题 6";
	font-family:"Arial","sans-serif";
	font-weight:bold;}
span.7Char
	{mso-style-name:"标题 7 Char";
	mso-style-link:"标题 7";
	font-weight:bold;}
span.8Char
	{mso-style-name:"标题 8 Char";
	mso-style-link:"标题 8";
	font-family:"Arial","sans-serif";}
span.9Char
	{mso-style-name:"标题 9 Char";
	mso-style-link:"标题 9";
	font-family:"Arial","sans-serif";}
span.Chara
	{mso-style-name:"脚注文本 Char";
	mso-style-link:脚注文本;
	font-family:宋体;}
span.Charb
	{mso-style-name:"批注文字 Char";
	mso-style-link:批注文字;
	font-family:宋体;}
span.Charc
	{mso-style-name:"页眉 Char";
	mso-style-link:页眉;
	font-family:宋体;}
span.Chard
	{mso-style-name:"页脚 Char";
	mso-style-link:页脚;
	font-family:宋体;}
span.Chare
	{mso-style-name:"日期 Char";
	mso-style-link:日期;
	font-family:宋体;}
span.HTMLChar
	{mso-style-name:"HTML 预设格式 Char\,HTML 预先格式化 Char\,HTML 预先格式化1 Char\,HTML 预先格式化2 Char\,HTML 预先格式化3 Char";
	mso-style-link:"HTML 预设格式\,HTML 预先格式化\,HTML 预先格式化1\,HTML 预先格式化2\,HTML 预先格式化3";
	font-family:宋体;}
span.Charf
	{mso-style-name:"批注主题 Char";
	mso-style-link:批注主题;
	font-family:宋体;
	font-weight:bold;}
span.Charf0
	{mso-style-name:"批注框文本 Char";
	mso-style-link:批注框文本;
	font-family:宋体;}
span.3CharChar1
	{mso-style-name:"图中文字3 Char Char1";
	font-family:宋体;}
span.5CharCharChar0
	{mso-style-name:"图中文字5号 Char Char Char";
	font-family:宋体;}
span.3CharChar3
	{mso-style-name:"图中文字3 Char Char3";
	font-family:宋体;}
span.3CharChar1Char
	{mso-style-name:"图中文字3 Char Char1 Char";
	font-family:宋体;}
span.3CharChar13
	{mso-style-name:"图中文字3 Char Char13";
	font-family:宋体;}
span.3CharChar12
	{mso-style-name:"图中文字3 Char Char12";
	font-family:宋体;}
span.3CharChar11
	{mso-style-name:"图中文字3 Char Char11";
	font-family:宋体;}
.MsoChpDefault
	{font-size:10.0pt;}
 /* Page Definitions */
 @page WordSection1
	{size:595.3pt 841.9pt;
	margin:72.0pt 54.0pt 72.0pt 54.0pt;
	layout-grid:15.6pt;}
div.WordSection1
	{page:WordSection1;}
 /* List Definitions */
 ol
	{margin-bottom:0cm;}
ul
	{margin-bottom:0cm;}
-->
</style>

</head>

<body lang=ZH-CN link=blue vlink=purple style='text-justify-trim:punctuation'>

<div class=WordSection1 style='layout-grid:15.6pt'>

<p class=ab><a name="_Toc53320611"><span style='font-family:黑体'>程序</span><span
lang=EN-US>8-9 linux/kernel/sys.c</span></a><span style='font-family:黑体'>程序</span></p>

<div class=a align=center style='text-align:center'><span lang=EN-US>

<hr size=4 width="100%" align=center>

</span></div>

<p class=a><span lang=EN-US>&nbsp; <u><span style='color:blue'>1</span></u> <b><i>/*</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp; <u><span style='color:blue'>2</span></u> <b><i>&nbsp;*&nbsp;
linux/kernel/sys.c</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp; <u><span style='color:blue'>3</span></u> <b><i>&nbsp;*</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp; <u><span style='color:blue'>4</span></u> <b><i>&nbsp;*&nbsp;
(C) 1991&nbsp; Linus Torvalds</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp; <u><span style='color:blue'>5</span></u> <b><i>&nbsp;*/</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp; <u><span style='color:blue'>6</span></u> </span></p>

<p class=a><span lang=EN-US>&nbsp; <u><span style='color:blue'>7</span></u>
#include &lt;errno.h&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;// </span>错误号头文件。包含系统中各种出错号。</p>

<p class=a><span lang=EN-US>&nbsp; <u><span style='color:blue'>8</span></u> </span></p>

<p class=a><span lang=EN-US>&nbsp; <u><span style='color:blue'>9</span></u>
#include &lt;linux/sched.h&gt;&nbsp; // </span>调度程序头文件。定义了任务结构<span lang=EN-US>task_struct</span>、任务<span
lang=EN-US>0</span>的数据，</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// </span>还有一些有关描述符参数设置和获取的嵌入式汇编函数宏语句。</p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>10</span></u>
#include &lt;linux/tty.h&gt;&nbsp;&nbsp;&nbsp; // tty</span>头文件，定义了有关<span
lang=EN-US>tty_io</span>，串行通信方面的参数、常数。</p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>11</span></u>
#include &lt;linux/kernel.h&gt; // </span>内核头文件。含有一些内核常用函数的原形定义。</p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>12</span></u>
#include &lt;linux/config.h&gt; // </span>内核常数配置文件。这里主要使用其中的系统名称常数符号信息。</p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>13</span></u>
#include &lt;asm/segment.h&gt;&nbsp; // </span>段操作头文件。定义了有关段寄存器操作的嵌入式汇编函数。</p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>14</span></u>
#include &lt;sys/times.h&gt;&nbsp;&nbsp;&nbsp; // </span>定义了进程中运行时间的结构<span
lang=EN-US>tms</span>以及<span lang=EN-US>times()</span>函数原型。</p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>15</span></u>
#include &lt;sys/utsname.h&gt;&nbsp; // </span>系统名称结构头文件。</p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>16</span></u>
#include &lt;sys/param.h&gt;&nbsp;&nbsp;&nbsp; // </span>系统参数头文件。含有系统一些全局常数符号。例如<span
lang=EN-US>HZ</span>等。</p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>17</span></u>
#include &lt;sys/resource.h&gt; // </span>系统资源头文件。含有有关进程资源使用情况的结构等信息。</p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>18</span></u>
#include &lt;string.h&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // </span>字符串头文件。字符串或内存字节序列操作函数。</p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>19</span></u> </span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>20</span></u> <b><i>/*
</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>21</span></u> <b><i>&nbsp;*
The timezone where the local system is located.&nbsp; Used as a default by some</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>22</span></u> <b><i>&nbsp;*
programs who obtain this value by using gettimeofday.</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>23</span></u> <b><i>&nbsp;*/</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; /* </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>本系统所在的时区（<span
lang=EN-US>timezone</span>）。作为某些程序使用<span lang=EN-US>gettimeofday</span>系统调用获取</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>时区的默认值。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; */</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>时区结构<span lang=EN-US>timezone</span>第<span
lang=EN-US>1</span>个字段（<span lang=EN-US>tz_minuteswest</span>）表示距格林尼治标准时间<span
lang=EN-US>GMT</span>以西的分钟</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>数；第<span lang=EN-US>2</span>个字段（<span
lang=EN-US>tz_dsttime</span>）是夏令时<span lang=EN-US>DST</span>（<span lang=EN-US>Daylight
Savings Time</span>）调整类型。 该结构</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>定义在<span lang=EN-US>include/sys/time.h</span>中。</p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>24</span></u>
struct <u><span style='color:blue'>timezone</span></u> <u><span
style='color:blue'>sys_tz</span></u> = { 0, 0};</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>25</span></u> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>根据进程组号<span
lang=EN-US>pgrp</span>取得进程组所属会话（<span lang=EN-US>session</span>）号。该函数在<span
lang=EN-US>kernel/exit.c</span>中实现。</p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>26</span></u>
extern int <u><span style='color:blue'>session_of_pgrp</span></u>(int pgrp);</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>27</span></u> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>返回日期和时间（<span
lang=EN-US>ftime – Fetch time</span>）。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>以下返回值是<span
lang=EN-US>-ENOSYS</span>的系统调用函数均表示在本版本内核中还未实现。</p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>28</span></u> int
<u><span style='color:blue'>sys_ftime</span></u>()</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>29</span></u> {</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>30</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>ENOSYS</span></u>;</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>31</span></u> }</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>32</span></u> </span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>33</span></u> int
<u><span style='color:blue'>sys_break</span></u>()</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>34</span></u> {</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>35</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>ENOSYS</span></u>;</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>36</span></u> }</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>37</span></u> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>用于当前进程对子进程进行调试<span
lang=EN-US>(debugging)</span>。</p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>38</span></u> int
<u><span style='color:blue'>sys_ptrace</span></u>()</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>39</span></u> {</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>40</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>ENOSYS</span></u>;</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>41</span></u> }</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>42</span></u> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>改变并打印终端行设置。</p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>43</span></u> int
<u><span style='color:blue'>sys_stty</span></u>()</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>44</span></u> {</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>45</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>ENOSYS</span></u>;</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>46</span></u> }</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>47</span></u> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>取终端行设置信息。</p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>48</span></u> int
<u><span style='color:blue'>sys_gtty</span></u>()</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>49</span></u> {</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>50</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>ENOSYS</span></u>;</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>51</span></u> }</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>52</span></u> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>修改文件名。</p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>53</span></u> int
<u><span style='color:blue'>sys_rename</span></u>()</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>54</span></u> {</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>55</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>ENOSYS</span></u>;</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>56</span></u> }</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>57</span></u> </span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>58</span></u> int
<u><span style='color:blue'>sys_prof</span></u>()</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>59</span></u> {</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>60</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>ENOSYS</span></u>;</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>61</span></u> }</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>62</span></u> </span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>63</span></u> <b><i>/*</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>64</span></u> <b><i>&nbsp;*
This is done BSD-style, with no consideration of the saved gid, except</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>65</span></u> <b><i>&nbsp;*
that if you set the effective gid, it sets the saved gid too.&nbsp; This </i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>66</span></u> <b><i>&nbsp;*
makes it possible for a setgid program to completely drop its privileges,</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>67</span></u> <b><i>&nbsp;*
which is often a useful assertion to make when you are doing a security</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>68</span></u> <b><i>&nbsp;*
audit over a program.</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>69</span></u> <b><i>&nbsp;*</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>70</span></u> <b><i>&nbsp;*
The general idea is that a program which uses just setregid() will be</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>71</span></u> <b><i>&nbsp;*
100% compatible with BSD.&nbsp; A program which uses just setgid() will be</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>72</span></u> <b><i>&nbsp;*
100% compatible with POSIX w/ Saved ID's. </i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>73</span></u> <b><i>&nbsp;*/</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; /*</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>以下是<span
lang=EN-US>BSD</span>形式的实现，没有考虑保存的<span lang=EN-US>gid</span>（<span lang=EN-US>saved
gid</span>或<span lang=EN-US>sgid</span>），除了当你</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>设置了有效的<span
lang=EN-US>gid</span>（<span lang=EN-US>effective gid</span>或<span lang=EN-US>egid</span>）时，保存的<span
lang=EN-US>gid</span>也会被设置。这使</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>得一个使用<span
lang=EN-US>setgid</span>的程序可以完全放弃其特权。当你在对一个程序进行安全审</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>计时，这通常是一种很好的处理方法。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>最基本的考虑是一个使用<span
lang=EN-US>setregid()</span>的程序将会与<span lang=EN-US>BSD</span>系统<span
lang=EN-US>100%</span>的兼容。而一</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>个使用<span
lang=EN-US>setgid()</span>和保存的<span lang=EN-US>gid</span>的程序将会与<span
lang=EN-US>POSIX 100%</span>的兼容。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; */</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>设置当前任务的实际以及<span
lang=EN-US>/</span>或者有效组<span lang=EN-US>ID</span>（<span lang=EN-US>gid</span>）。如果任务没有超级用户特权，那么只能互</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>换其实际组<span lang=EN-US>ID
</span>和有效组<span lang=EN-US> ID</span>。如果任务具有超级用户特权，就能任意设置有效的和实际的组</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // ID</span>。保留的<span
lang=EN-US>gid</span>（<span lang=EN-US>saved gid</span>）被设置成与有效<span
lang=EN-US>gid</span>。实际组<span lang=EN-US>ID</span>是指进程当前的<span lang=EN-US>gid</span>。</p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>74</span></u> int
<u><span style='color:blue'>sys_setregid</span></u>(int rgid, int egid)</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>75</span></u> {</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>76</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if (rgid&gt;0) {</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>77</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if ((<u><span style='color:blue'>current</span></u>-&gt;gid == rgid) || </span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>78</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>suser</span></u>())</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>79</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>current</span></u>-&gt;gid = rgid;</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>80</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
else</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>81</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return(-<u><span
style='color:blue'>EPERM</span></u>);</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>82</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>83</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if (egid&gt;0) {</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>84</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if ((<u><span style='color:blue'>current</span></u>-&gt;gid == egid) ||</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>85</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
(<u><span style='color:blue'>current</span></u>-&gt;egid == egid) ||</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>86</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>suser</span></u>()) {</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>87</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>current</span></u>-&gt;egid = egid;</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>88</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>current</span></u>-&gt;sgid = egid;</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>89</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
} else</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>90</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return(-<u><span style='color:blue'>EPERM</span></u>);</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>91</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>92</span></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return 0;</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>93</span></u> }</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>94</span></u> </span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>95</span></u> <b><i>/*</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>96</span></u> <b><i>&nbsp;*
setgid() is implemeneted like SysV w/ SAVED_IDS </i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>97</span></u> <b><i>&nbsp;*/</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; /*</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * setgid()</span>的实现与具有<span
lang=EN-US>SAVED_IDS</span>的<span lang=EN-US>SYSV</span>的实现方法相似。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; */</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>设置进程组号<span
lang=EN-US>(gid)</span>。如果任务没有超级用户特权，它可以使用 <span lang=EN-US>setgid() </span>将其有效<span
lang=EN-US>gid</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>（<span lang=EN-US>effective
gid</span>）设置为成其保留<span lang=EN-US>gid(saved gid)</span>或其实际<span lang=EN-US>gid(real
gid)</span>。如果任务</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>有超级用户特权，则实际<span
lang=EN-US>gid</span>、有效<span lang=EN-US>gid</span>和保留<span lang=EN-US>gid</span>都被设置成参数指定的<span
lang=EN-US>gid</span>。</p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>98</span></u> int
<u><span style='color:blue'>sys_setgid</span></u>(int gid)</span></p>

<p class=a><span lang=EN-US>&nbsp;<u><span style='color:blue'>99</span></u> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>100</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (<u><span
style='color:blue'>suser</span></u>())</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>101</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>current</span></u>-&gt;gid = <u><span
style='color:blue'>current</span></u>-&gt;egid = <u><span style='color:blue'>current</span></u>-&gt;sgid
= gid;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>102</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ((gid == <u><span
style='color:blue'>current</span></u>-&gt;gid) || (gid == <u><span
style='color:blue'>current</span></u>-&gt;sgid))</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>103</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>current</span></u>-&gt;egid = gid;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>104</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>105</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>EPERM</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>106</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>107</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>108</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>打开或关闭进程计帐功能。</p>

<p class=a><u><span lang=EN-US style='color:blue'>109</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_acct</span></u>()</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>110</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>111</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -<u><span
style='color:blue'>ENOSYS</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>112</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>113</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>映射任意物理内存到进程的虚拟地址空间。</p>

<p class=a><u><span lang=EN-US style='color:blue'>114</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_phys</span></u>()</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>115</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>116</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -<u><span
style='color:blue'>ENOSYS</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>117</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>118</span></u><span
lang=EN-US> </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>119</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_lock</span></u>()</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>120</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>121</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -<u><span
style='color:blue'>ENOSYS</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>122</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>123</span></u><span
lang=EN-US> </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>124</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_mpx</span></u>()</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>125</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>126</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -<u><span
style='color:blue'>ENOSYS</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>127</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>128</span></u><span
lang=EN-US> </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>129</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_ulimit</span></u>()</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>130</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>131</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -<u><span
style='color:blue'>ENOSYS</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>132</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>133</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>返回从<span lang=EN-US> 1970<span lang=EN-US><span lang=EN-US>年1</span></span><span lang=EN-US><span lang=EN-US>月1</span></span><span
 lang=EN-US><span lang=EN-US>日</span></span>00:00:00 GMT </span>开始计时的时间值（秒）。如果<span
lang=EN-US>tloc</span>不为<span lang=EN-US>null</span>，</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>则时间值也存储在那里。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>由于参数是一个指针，而其所指位置在用户空间，因此需要使用函数
<span lang=EN-US>put_fs_long() </span>来</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>访问该值。在进入内核中运行时，段寄存器<span
lang=EN-US>fs</span>被默认地指向当前用户数据空间。因此该</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>函数就可利用<span
lang=EN-US>fs</span>来访问用户空间中的值。</p>

<p class=a><u><span lang=EN-US style='color:blue'>134</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_time</span></u>(long * tloc)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>135</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>136</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int i;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>137</span></u><span
lang=EN-US> </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>138</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = <u><span
style='color:blue'>CURRENT_TIME</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>139</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (tloc) {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>140</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>verify_area</span></u>(tloc,4);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// </span>验证内存容量是否够（这里是<span lang=EN-US>4</span>字节）。</p>

<p class=a><u><span lang=EN-US style='color:blue'>141</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>put_fs_long</span></u>(i,(unsigned long *)tloc);&nbsp;&nbsp;
// </span>放入用户数据段<span lang=EN-US>tloc</span>处。</p>

<p class=a><u><span lang=EN-US style='color:blue'>142</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>143</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return i;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>144</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>145</span></u><span
lang=EN-US> </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>146</span></u><span
lang=EN-US> <b><i>/*</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>147</span></u><span
lang=EN-US> <b><i>&nbsp;* Unprivileged users may change the real user id to the
effective uid</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>148</span></u><span
lang=EN-US> <b><i>&nbsp;* or vice versa.&nbsp; (BSD-style)</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>149</span></u><span
lang=EN-US> <b><i>&nbsp;*</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>150</span></u><span
lang=EN-US> <b><i>&nbsp;* When you set the effective uid, it sets the saved uid
too.&nbsp; This </i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>151</span></u><span
lang=EN-US> <b><i>&nbsp;* makes it possible for a setuid program to completely
drop its privileges,</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>152</span></u><span
lang=EN-US> <b><i>&nbsp;* which is often a useful assertion to make when you
are doing a security</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>153</span></u><span
lang=EN-US> <b><i>&nbsp;* audit over a program.</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>154</span></u><span
lang=EN-US> <b><i>&nbsp;*</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>155</span></u><span
lang=EN-US> <b><i>&nbsp;* The general idea is that a program which uses just
setreuid() will be</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>156</span></u><span
lang=EN-US> <b><i>&nbsp;* 100% compatible with BSD.&nbsp; A program which uses just
setuid() will be</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>157</span></u><span
lang=EN-US> <b><i>&nbsp;* 100% compatible with POSIX w/ Saved ID's. </i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>158</span></u><span
lang=EN-US> <b><i>&nbsp;*/</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; /* </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>无特权的用户可以见实际的<span
lang=EN-US>uid</span>（<span lang=EN-US>real uid</span>）改成有效的<span lang=EN-US>uid</span>（<span
lang=EN-US>effective uid</span>），</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>反之也然。（<span
lang=EN-US>BSD</span>形式的实现）</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>当你设置有效的<span
lang=EN-US>uid </span>时，它同时也设置了保存的<span lang=EN-US> uid</span>。这使得一个使用<span
lang=EN-US> setuid</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>的程序可以完全放弃其特权。当你在对一个程序进行安全审计时，这通常是一种</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>很好的处理方法。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>最基本的考虑是一个使用<span
lang=EN-US> setreuid()</span>的程序将会与<span lang=EN-US> BSD</span>系统<span
lang=EN-US>100%</span>的兼容。而一</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>个使用<span
lang=EN-US>setuid()</span>和保存的<span lang=EN-US>gid</span>的程序将会与<span
lang=EN-US>POSIX 100%</span>的兼容。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; */</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>设置任务的实际以及<span
lang=EN-US>/</span>或者有效的用户<span lang=EN-US>ID</span>（<span lang=EN-US>uid</span>）。如果任务没有超级用户特权，那么只能</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>互换其实际的<span
lang=EN-US>uid </span>和有效的<span lang=EN-US>uid</span>。如果任务具有超级用户特权，就能任意设置有效的和实</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>际的用户<span lang=EN-US>ID</span>。保存的<span
lang=EN-US>uid</span>（<span lang=EN-US>saved uid</span>）被设置成与有效<span
lang=EN-US>uid</span>同值。</p>

<p class=a><u><span lang=EN-US style='color:blue'>159</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_setreuid</span></u>(int ruid,
int euid)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>160</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>161</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int old_ruid = <u><span
style='color:blue'>current</span></u>-&gt;uid;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>162</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>163</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (ruid&gt;0) {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>164</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if ((<u><span style='color:blue'>current</span></u>-&gt;euid==ruid) ||</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>165</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
(old_ruid == ruid) ||</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>166</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>suser</span></u>())</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>167</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>current</span></u>-&gt;uid = ruid;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>168</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
else</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>169</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return(-<u><span style='color:blue'>EPERM</span></u>);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>170</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>171</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (euid&gt;0) {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>172</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if
((old_ruid == euid) ||</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>173</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
(<u><span style='color:blue'>current</span></u>-&gt;euid == euid) ||</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>174</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>suser</span></u>()) {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>175</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>current</span></u>-&gt;euid = euid;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>176</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>current</span></u>-&gt;suid = euid;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>177</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
} else {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>178</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>current</span></u>-&gt;uid = old_ruid;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>179</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return(-<u><span style='color:blue'>EPERM</span></u>);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>180</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>181</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>182</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>183</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>184</span></u><span
lang=EN-US> </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>185</span></u><span
lang=EN-US> <b><i>/*</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>186</span></u><span
lang=EN-US> <b><i>&nbsp;* setuid() is implemeneted like SysV w/ SAVED_IDS </i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>187</span></u><span
lang=EN-US> <b><i>&nbsp;* </i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>188</span></u><span
lang=EN-US> <b><i>&nbsp;* Note that SAVED_ID's is deficient in that a setuid
root program</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>189</span></u><span
lang=EN-US> <b><i>&nbsp;* like sendmail, for example, cannot set its uid to be
a normal </i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>190</span></u><span
lang=EN-US> <b><i>&nbsp;* user and then switch back, because if you're root,
setuid() sets</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>191</span></u><span
lang=EN-US> <b><i>&nbsp;* the saved uid too.&nbsp; If you don't like this,
blame the bright people</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>192</span></u><span
lang=EN-US> <b><i>&nbsp;* in the POSIX commmittee and/or USG.&nbsp; Note that
the BSD-style setreuid()</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>193</span></u><span
lang=EN-US> <b><i>&nbsp;* will allow a root program to temporarily drop
privileges and be able to</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>194</span></u><span
lang=EN-US> <b><i>&nbsp;* regain them by swapping the real and effective
uid.&nbsp; </i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>195</span></u><span
lang=EN-US> <b><i>&nbsp;*/</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp; &nbsp;/*</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * setuid()</span>的实现与具有<span
lang=EN-US>SAVED_IDS</span>的<span lang=EN-US>SYSV</span>的实现方法相似。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; *</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>请注意使用<span
lang=EN-US>SAVED_ID</span>的<span lang=EN-US>setuid()</span>在某些方面是不完善的。例如，一个使用</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * setuid</span>的超级用户程序<span
lang=EN-US>sendmail</span>就做不到把其<span lang=EN-US>uid</span>设置成一个普通用户的</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * uid</span>，然后再交换回来。 因为如果你是一个超级用户，<span
lang=EN-US>setuid() </span>也同时会</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>设置保存的<span
lang=EN-US>uid</span>。如果你不喜欢这样的做法的话，就责怪<span lang=EN-US>POSIX</span>组委会以及</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * /</span>或者<span
lang=EN-US>USG</span>中的聪明人吧。不过请注意<span lang=EN-US>BSD</span>形式的<span
lang=EN-US>setreuid()</span>实现能够允许</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>一个超级用户程序临时放弃特权，并且能通过交换实际的和有效的<span
lang=EN-US> uid </span>而</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>再次获得特权。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; */</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>设置任务用户<span
lang=EN-US>ID</span>（<span lang=EN-US>uid</span>）。如果任务没有超级用户特权，它可以使用<span
lang=EN-US>setuid()</span>将其有效的</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // uid</span>（<span lang=EN-US>effective
uid</span>）设置成其保存的<span lang=EN-US>uid</span>（<span lang=EN-US>saved uid</span>）或其实际的<span
lang=EN-US>uid</span>（<span lang=EN-US>real uid</span>）。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>如果任务有超级用户特权，则实际的<span
lang=EN-US>uid</span>、有效的<span lang=EN-US>uid</span>和保存的<span lang=EN-US>uid</span>都会被设置成参数指</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>定的<span lang=EN-US>uid</span>。</p>

<p class=a><u><span lang=EN-US style='color:blue'>196</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_setuid</span></u>(int uid)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>197</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>198</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (<u><span
style='color:blue'>suser</span></u>())</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>199</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>current</span></u>-&gt;uid = <u><span
style='color:blue'>current</span></u>-&gt;euid = <u><span style='color:blue'>current</span></u>-&gt;suid
= uid;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>200</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ((uid == <u><span
style='color:blue'>current</span></u>-&gt;uid) || (uid == <u><span
style='color:blue'>current</span></u>-&gt;suid))</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>201</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>current</span></u>-&gt;euid = uid;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>202</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>203</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>EPERM</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>204</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return(0);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>205</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>206</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>设置系统开机时间。参数<span
lang=EN-US>tptr</span>是从<span
 lang=EN-US>1970</span>年<span lang=EN-US>1</span>月<span lang=EN-US>1</span>日<span
lang=EN-US>00:00:00 GMT</span>开始计时的时间值（秒）。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>调用进程必须具有超级用户权限。其中<span
lang=EN-US>HZ=100</span>，是内核系统运行频率。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>由于参数是一个指针，而其所指位置在用户空间，因此需要使用函数<span
lang=EN-US>get_fs_long()</span>来访问该</p>

<p class=a><span lang=EN-US>&nbsp; &nbsp;&nbsp;// </span>值。在进入内核中运行时，段寄存器 <span
lang=EN-US>fs </span>被默认地指向当前用户数据空间。因此该函数就可利</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>用<span lang=EN-US>fs</span>来访问用户空间中的值。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>函数参数提供的当前时间值减去系统已经运行的时间秒值（<span
lang=EN-US>jiffies/HZ</span>）即是开机时间秒值。</p>

<p class=a><u><span lang=EN-US style='color:blue'>207</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_stime</span></u>(long * tptr)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>208</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>209</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!<u><span
style='color:blue'>suser</span></u>())&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// </span>如果不是超级用户则出错返回（许可）。</p>

<p class=a><u><span lang=EN-US style='color:blue'>210</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>EPERM</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>211</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <u><span
style='color:blue'>startup_time</span></u> = <u><span style='color:blue'>get_fs_long</span></u>((unsigned
long *)tptr) - <u><span style='color:blue'>jiffies</span></u>/<u><span
style='color:blue'>HZ</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>212</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <u><span
style='color:blue'>jiffies_offset</span></u> = 0;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>213</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>214</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>215</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>获取当前任务运行时间统计值。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>在<span lang=EN-US>tbuf</span>所指用户数据空间处返回<span
lang=EN-US>tms</span>结构的任务运行时间统计值。<span lang=EN-US>tms</span>结构中包括进程用户</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>运行时间、内核（系统）时间、子进程用户运行时间、子进程系统运行时间。函数返回值是</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>系统运行到当前的嘀嗒数。</p>

<p class=a><u><span lang=EN-US style='color:blue'>216</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_times</span></u>(struct <u><span
style='color:blue'>tms</span></u> * tbuf)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>217</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>218</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (tbuf) {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>219</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>verify_area</span></u>(tbuf,sizeof *tbuf);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>220</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>put_fs_long</span></u>(<u><span style='color:blue'>current</span></u>-&gt;<u><span
style='color:blue'>utime</span></u>,(unsigned long *)&amp;tbuf-&gt;tms_utime);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>221</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>put_fs_long</span></u>(<u><span style='color:blue'>current</span></u>-&gt;<u><span
style='color:blue'>stime</span></u>,(unsigned long *)&amp;tbuf-&gt;tms_stime);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>222</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>put_fs_long</span></u>(<u><span style='color:blue'>current</span></u>-&gt;cutime,(unsigned
long *)&amp;tbuf-&gt;tms_cutime);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>223</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>put_fs_long</span></u>(<u><span style='color:blue'>current</span></u>-&gt;cstime,(unsigned
long *)&amp;tbuf-&gt;tms_cstime);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>224</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>225</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return <u><span
style='color:blue'>jiffies</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>226</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>227</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>当参数<span lang=EN-US>end_data_seg</span>数值合理，并且系统确实有足够的内存，而且进程没有超越其最大数据</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>段大小时，该函数设置数据段末尾为<span
lang=EN-US>end_data_seg</span>指定的值。该值必须大于代码结尾并且要</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>小于堆栈结尾<span
lang=EN-US>16KB</span>。返回值是数据段的新结尾值（如果返回值与要求值不同，则表明有错误</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>发生）。该函数并不被用户直接调用，而由<span
lang=EN-US>libc</span>库函数进行包装，并且返回值也不一样。</p>

<p class=a><u><span lang=EN-US style='color:blue'>228</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_brk</span></u>(unsigned long
end_data_seg)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>229</span></u><span
lang=EN-US> {</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>如果参数值大于代码结尾，并且小于（堆栈<span
lang=EN-US> - 16KB</span>），则设置新数据段结尾值。</p>

<p class=a><u><span lang=EN-US style='color:blue'>230</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (end_data_seg
&gt;= <u><span style='color:blue'>current</span></u>-&gt;end_code &amp;&amp;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>231</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
end_data_seg &lt; <u><span style='color:blue'>current</span></u>-&gt;start_stack
- 16384)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>232</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>current</span></u>-&gt;<u><span style='color:blue'>brk</span></u>
= end_data_seg;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>233</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return <u><span
style='color:blue'>current</span></u>-&gt;<u><span style='color:blue'>brk</span></u>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;// </span>返回进程当前的数据段结尾值。</p>

<p class=a><u><span lang=EN-US style='color:blue'>234</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>235</span></u><span
lang=EN-US> </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>236</span></u><span
lang=EN-US> <b><i>/*</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>237</span></u><span
lang=EN-US> <b><i>&nbsp;* This needs some heave checking ...</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>238</span></u><span
lang=EN-US> <b><i>&nbsp;* I just haven't get the stomach for it. I also don't
fully</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>239</span></u><span
lang=EN-US> <b><i>&nbsp;* understand sessions/pgrp etc. Let somebody who does
explain it.</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>240</span></u><span
lang=EN-US> <b><i>&nbsp;*</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>241</span></u><span
lang=EN-US> <b><i>&nbsp;* OK, I think I have the protection semantics right....
this is really</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>242</span></u><span
lang=EN-US> <b><i>&nbsp;* only important on a multi-user system anyway, to make
sure one user</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>243</span></u><span
lang=EN-US> <b><i>&nbsp;* can't send a signal to a process owned by
another.&nbsp; -TYT, 12/12/91</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>244</span></u><span
lang=EN-US> <b><i>&nbsp;*/</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; /*</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>下面代码需要某些严格的检查<span
lang=EN-US>…</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>我只是没有胃口来做这些。我也不完全明白<span
lang=EN-US>sessions/pgrp</span>等的含义。还是让</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>了解它们的人来做吧。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * OK</span>，我想我已经正确地实现了保护语义<span
lang=EN-US>...</span>。总之，这其实只对多用户系统是</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>重要的，以确定一个用户不能向其他用户的进程发送信号。<span
lang=EN-US> -TYT 12/12/91</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; */</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>设置指定进程<span
lang=EN-US>pid</span>的进程组号为<span lang=EN-US>pgid</span>。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>参数<span lang=EN-US>pid
</span>是指定进程的进程号。如果它为<span lang=EN-US>0</span>，则让<span lang=EN-US>pid</span>等于当前进程的进程号。参数<span
lang=EN-US>pgid</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>是指定的进程组号。如果它为<span
lang=EN-US>0</span>，则让它等于进程<span lang=EN-US>pid</span>的进程组号。如果该函数用于将进程</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>从一个进程组移到另一个进程组，则这两个进程组必须属于同一个会话<span
lang=EN-US>(session)</span>。在这种</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>情况下，参数<span
lang=EN-US>pgid </span>指定了要加入的现有进程组<span lang=EN-US>ID</span>，此时该组的会话<span
lang=EN-US>ID</span>必须与将要加入进</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>程的相同<span lang=EN-US>(263</span>行<span
lang=EN-US>)</span>。</p>

<p class=a><u><span lang=EN-US style='color:blue'>245</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_setpgid</span></u>(int pid, int
pgid)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>246</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>247</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int i; </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>248</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>如果参数<span lang=EN-US>pid</span>为<span
lang=EN-US>0</span>，则<span lang=EN-US>pid</span>取值为当前进程的进程号<span lang=EN-US>pid</span>。如果参数<span
lang=EN-US>pgid</span>为<span lang=EN-US>0</span>，则<span lang=EN-US>pgid</span>也</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>取值为当前进程的<span
lang=EN-US>pid</span>。<span lang=EN-US>[?? </span>这里与<span lang=EN-US>POSIX</span>标准的描述有出入<span
lang=EN-US> ]</span>。若<span lang=EN-US> pgid</span>小于<span lang=EN-US>0</span>，则返回</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>无效错误码。</p>

<p class=a><u><span lang=EN-US style='color:blue'>249</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!pid)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>250</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
pid = <u><span style='color:blue'>current</span></u>-&gt;pid;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>251</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!pgid)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>252</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
pgid = <u><span style='color:blue'>current</span></u>-&gt;pid;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>253</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (pgid &lt; 0)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>254</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>EINVAL</span></u>;</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>扫描任务数组，查找指定进程号<span
lang=EN-US> pid </span>的任务。如果找到了进程号是<span lang=EN-US>pid </span>的进程，并且该进程</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>的父进程就是当前进程或者该进程就是当前进程，那么若该任务已经是会话首领，则出错返回。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>若该任务的会话号（<span
lang=EN-US>session</span>）与当前进程的不同，或者指定的进程组号<span lang=EN-US>pgid</span>与<span
lang=EN-US>pid</span>不同并且</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // pgid </span>进程组所属会话号与当前进程所属会话号不同，则也出错返回。
否则把查找到的进程的</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // pgrp</span>设置为<span
lang=EN-US>pgid</span>，并返回<span lang=EN-US>0</span>。若没有找到指定<span lang=EN-US>pid</span>的进程，则返回进程不存在出错码。</p>

<p class=a><u><span lang=EN-US style='color:blue'>255</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (i=0 ; i&lt;<u><span
style='color:blue'>NR_TASKS</span></u> ; i++)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>256</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if (<u><span style='color:blue'>task</span></u>[i] &amp;&amp; (<u><span
style='color:blue'>task</span></u>[i]-&gt;pid == pid) &amp;&amp;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>257</span></u><span
lang=EN-US> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((<u><span
style='color:blue'>task</span></u>[i]-&gt;p_pptr == <u><span style='color:blue'>current</span></u>)
|| </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>258</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
(<u><span style='color:blue'>task</span></u>[i] == <u><span style='color:blue'>current</span></u>)))
{</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>259</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if (<u><span style='color:blue'>task</span></u>[i]-&gt;leader)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>260</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>EPERM</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>261</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if ((<u><span style='color:blue'>task</span></u>[i]-&gt;session != <u><span
style='color:blue'>current</span></u>-&gt;session) ||</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>262</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
((pgid != pid) &amp;&amp; </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>263</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
(<u><span style='color:blue'>session_of_pgrp</span></u>(pgid) != <u><span
style='color:blue'>current</span></u>-&gt;session)))</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>264</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>EPERM</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>265</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>task</span></u>[i]-&gt;pgrp = pgid;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>266</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return 0;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>267</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>268</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -<u><span
style='color:blue'>ESRCH</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>269</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>270</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>返回当前进程的进程组号。与<span
lang=EN-US>getpgid(0)</span>等同。</p>

<p class=a><u><span lang=EN-US style='color:blue'>271</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_getpgrp</span></u>(void)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>272</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>273</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return <u><span
style='color:blue'>current</span></u>-&gt;pgrp;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>274</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>275</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>创建一个会话<span
lang=EN-US>(session)</span>（即设置其<span lang=EN-US>leader=1</span>），并且设置其会话号<span
lang=EN-US>=</span>其组号<span lang=EN-US>=</span>其进程号。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>如果当前进程已是会话首领并且不是超级用户，则出错返回。否则设置当前进程为新会话</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>首领（<span lang=EN-US>leader
= 1</span>），并且设置当前进程会话号 <span lang=EN-US>session</span>和组号<span lang=EN-US>pgrp</span>都等于进程号<span
lang=EN-US>pid</span>，</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>而且设置当前进程没有控制终端。最后系统调用返回会话号。</p>

<p class=a><u><span lang=EN-US style='color:blue'>276</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_setsid</span></u>(void)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>277</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>278</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (<u><span
style='color:blue'>current</span></u>-&gt;leader &amp;&amp; !<u><span
style='color:blue'>suser</span></u>())</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>279</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;return -<u><span style='color:blue'>EPERM</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>280</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <u><span
style='color:blue'>current</span></u>-&gt;leader = 1;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>281</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <u><span
style='color:blue'>current</span></u>-&gt;session = <u><span style='color:blue'>current</span></u>-&gt;pgrp
= <u><span style='color:blue'>current</span></u>-&gt;pid;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>282</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <u><span
style='color:blue'>current</span></u>-&gt;tty = -1;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// </span>表示当前进程没有控制终端。</p>

<p class=a><u><span lang=EN-US style='color:blue'>283</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return <u><span
style='color:blue'>current</span></u>-&gt;pgrp;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>284</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>285</span></u><span
lang=EN-US> </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>286</span></u><span
lang=EN-US> <b><i>/*</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>287</span></u><span
lang=EN-US> <b><i>&nbsp;* Supplementary group ID's</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>288</span></u><span
lang=EN-US> <b><i>&nbsp;*/</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; /*</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>进程的其他用户组号。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; */</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>取当前进程其他辅助用户组号。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>任务数据结构中<span
lang=EN-US>groups[]</span>数组保存着进程同时所属的多个用户组号。该数组共<span lang=EN-US>NGROUPS</span>个项，</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>若某项的值是<span
lang=EN-US>NOGROUP</span>（即为<span lang=EN-US> -1</span>），则表示从该项开始以后所有项都空闲。否则数组项中保</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>存的是用户组号。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>参数<span lang=EN-US>gidsetsize</span>是获取的用户组号个数；<span
lang=EN-US>grouplist</span>是存储这些用户组号的用户空间缓存。</p>

<p class=a><u><span lang=EN-US style='color:blue'>289</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_getgroups</span></u>(int
gidsetsize, <u><span style='color:blue'>gid_t</span></u> *grouplist)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>290</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>291</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
int&nbsp;&nbsp;&nbsp;&nbsp; i;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>292</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>首先验证<span lang=EN-US>grouplist</span>指针所指的用户缓存空间是否足够，然后从当前进程结构的<span
lang=EN-US>groups[]</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>数组中逐个取得用户组号并复制到用户缓存中。在复制过程中，如果<span
lang=EN-US> groups[] </span>中的项数</p>

<p class=a><span lang=EN-US>&nbsp; &nbsp;&nbsp;// </span>大于给定的参数<span
lang=EN-US> gidsetsize </span>所指定的个数，则表示用户给出的缓存太小，不能容下当前</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>进程所有组号，因此此次取组号操作会出错返回。若复制过程正常，则函数最后会返回复</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>制的用户组号个数。（<span
lang=EN-US>gidsetsize – gid set size</span>，用户组号集大小）。</p>

<p class=a><u><span lang=EN-US style='color:blue'>293</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (gidsetsize)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>294</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>verify_area</span></u>(grouplist, sizeof(<u><span
style='color:blue'>gid_t</span></u>) * gidsetsize);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>295</span></u><span
lang=EN-US> </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>296</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (i = 0; (i &lt;
<u><span style='color:blue'>NGROUPS</span></u>) &amp;&amp; (<u><span
style='color:blue'>current</span></u>-&gt;groups[i] != <u><span
style='color:blue'>NOGROUP</span></u>);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>297</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
i++, grouplist++) {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>298</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if (gidsetsize) {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>299</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if (i &gt;= gidsetsize)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>300</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>EINVAL</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>301</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>put_fs_word</span></u>(<u><span style='color:blue'>current</span></u>-&gt;groups[i],
(short *) grouplist);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>302</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>303</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>304</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return(i);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// </span>返回实际含有的用户组号个数。</p>

<p class=a><u><span lang=EN-US style='color:blue'>305</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>306</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>设置当前进程同时所属的其他辅助用户组号。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>参数<span lang=EN-US>gidsetsize</span>是将设置的用户组号个数；<span
lang=EN-US>grouplist</span>是含有用户组号的用户空间缓存。</p>

<p class=a><u><span lang=EN-US style='color:blue'>307</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_setgroups</span></u>(int
gidsetsize, <u><span style='color:blue'>gid_t</span></u> *grouplist)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>308</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>309</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
int&nbsp;&nbsp;&nbsp;&nbsp; i;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>310</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>首先查权限和参数的有效性。只有超级用户可以修改或设置当前进程的辅助用户组号，而且</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>设置的项数不能超过进程的<span
lang=EN-US>groups[NGROUPS]</span>数组的容量。然后从用户缓冲中逐个复制用户</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>组号，共<span lang=EN-US>gidsetsize</span>个。如果复制的个数没有填满<span
lang=EN-US>groups[]</span>，则在随后一项上填上值为<span lang=EN-US>-1</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>的项（<span lang=EN-US>NOGROUP</span>）。最后函数返回<span
lang=EN-US>0</span>。</p>

<p class=a><u><span lang=EN-US style='color:blue'>311</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!<u><span
style='color:blue'>suser</span></u>())</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>312</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>EPERM</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>313</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (gidsetsize &gt;
<u><span style='color:blue'>NGROUPS</span></u>)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>314</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>EINVAL</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>315</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (i = 0; i &lt;
gidsetsize; i++, grouplist++) {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>316</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>current</span></u>-&gt;groups[i] = <u><span
style='color:blue'>get_fs_word</span></u>((unsigned short *) grouplist);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>317</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>318</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (i &lt; <u><span
style='color:blue'>NGROUPS</span></u>)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>319</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>current</span></u>-&gt;groups[i] = <u><span
style='color:blue'>NOGROUP</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>320</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>321</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>322</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>检查当前进程是否在指定的用户组<span
lang=EN-US>grp</span>中。是则返回<span lang=EN-US>1</span>，否则返回<span lang=EN-US>0</span>。</p>

<p class=a><u><span lang=EN-US style='color:blue'>323</span></u><span
lang=EN-US> int <u><span style='color:blue'>in_group_p</span></u>(<u><span
style='color:blue'>gid_t</span></u> grp)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>324</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>325</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
int&nbsp;&nbsp;&nbsp;&nbsp; i;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>326</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>如果当前进程的有效组号就是<span
lang=EN-US>grp</span>，则表示进程属于<span lang=EN-US>grp</span>进程组。函数返回<span
lang=EN-US>1</span>。否则就在</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>进程的辅助用户组数组中扫描是否有<span
lang=EN-US> grp </span>进程组号。若有则函数也返回<span lang=EN-US>1</span>。若扫描到值</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>为<span lang=EN-US>
NOGROUP </span>的项，表示已扫描完全部有效项而没有发现匹配的组号，因此函数返回<span lang=EN-US>0</span>。</p>

<p class=a><u><span lang=EN-US style='color:blue'>327</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (grp == <u><span
style='color:blue'>current</span></u>-&gt;egid)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>328</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return 1;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>329</span></u><span
lang=EN-US> </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>330</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (i = 0; i &lt; <u><span
style='color:blue'>NGROUPS</span></u>; i++) {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>331</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if (<u><span style='color:blue'>current</span></u>-&gt;groups[i] == <u><span
style='color:blue'>NOGROUP</span></u>)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>332</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
break;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>333</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if (<u><span style='color:blue'>current</span></u>-&gt;groups[i] == grp)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>334</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return 1;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>335</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>336</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>337</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>338</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // utsname</span>结构含有一些字符串字段。用于保存系统的名称。其中包含<span
lang=EN-US>5</span>个字段，分别是：</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>当前操作系统的名称、网络节点名称（主机名）、当前操作系统发行级别、操作系统版本</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>号以及系统运行的硬件类型名称。该结构定义在<span
lang=EN-US> include/sys/utsname.h </span>文件中。 这里</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>内核使用<span lang=EN-US>
include/linux/config.h </span>文件中的常数符号设置了它们的默认值。它们分别为</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // “Linux</span>”，“<span
lang=EN-US>(none)</span>”，“<span
 lang=EN-US>0</span>”，“<span
 lang=EN-US>0.12</span>”，“<span lang=EN-US>i386<span
 lang=EN-US><span lang=EN-US>”</span></span><span lang=EN-US>。</span></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>339</span></u><span
lang=EN-US> static struct <u><span style='color:blue'>utsname</span></u> <u><span
style='color:blue'>thisname</span></u> = {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>340</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <u><span
style='color:blue'>UTS_SYSNAME</span></u>, <u><span style='color:blue'>UTS_NODENAME</span></u>,
<u><span style='color:blue'>UTS_RELEASE</span></u>, <u><span style='color:blue'>UTS_VERSION</span></u>,
<u><span style='color:blue'>UTS_MACHINE</span></u></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>341</span></u><span
lang=EN-US> };</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>342</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>获取系统名称等信息。</p>

<p class=a><u><span lang=EN-US style='color:blue'>343</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_uname</span></u>(struct <u><span
style='color:blue'>utsname</span></u> * name)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>344</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>345</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int i;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>346</span></u><span
lang=EN-US> </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>347</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!name) return -<u><span
style='color:blue'>ERROR</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>348</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <u><span
style='color:blue'>verify_area</span></u>(name,sizeof *name);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>349</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(i=0;i&lt;sizeof
*name;i++)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>350</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>put_fs_byte</span></u>(((char *) &amp;<u><span
style='color:blue'>thisname</span></u>)[i],i+(char *) name);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>351</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>352</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>353</span></u><span
lang=EN-US> </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>354</span></u><span
lang=EN-US> <b><i>/*</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>355</span></u><span
lang=EN-US> <b><i>&nbsp;* Only sethostname; gethostname can be implemented by
calling uname()</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>356</span></u><span
lang=EN-US> <b><i>&nbsp;*/</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; /*</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>通过调用<span
lang=EN-US>uname()</span>只能实现<span lang=EN-US>sethostname</span>和<span
lang=EN-US>gethostname</span>。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; */</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>设置系统主机名（系统的网络节点名）。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>参数<span lang=EN-US>name</span>指针指向用户数据区中含有主机名字符串的缓冲区；<span
lang=EN-US>len</span>是主机名字符串长度。</p>

<p class=a><u><span lang=EN-US style='color:blue'>357</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_sethostname</span></u>(char
*name, int len)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>358</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>359</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
int&nbsp;&nbsp;&nbsp;&nbsp; i;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>360</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>系统主机名只能由超级用户设置或修改，并且主机名长度不能超过最大长度<span
lang=EN-US>MAXHOSTNAMELEN</span>。</p>

<p class=a><u><span lang=EN-US style='color:blue'>361</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!<u><span
style='color:blue'>suser</span></u>())</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>362</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>EPERM</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>363</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (len &gt; <u><span
style='color:blue'>MAXHOSTNAMELEN</span></u>)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>364</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>EINVAL</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>365</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (i=0; i &lt;
len; i++) {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>366</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if ((<u><span style='color:blue'>thisname</span></u>.nodename[i] = <u><span
style='color:blue'>get_fs_byte</span></u>(name+i)) == 0)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>367</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
break;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>368</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>在复制完毕后，如果用户提供的字符串中没有包含<span
lang=EN-US>NULL</span>字符，那么若复制的主机名长度还没有</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>超过<span lang=EN-US>
MAXHOSTNAMELEN</span>，则在主机名字符串后添加一个<span lang=EN-US>NULL</span>。若已经填满<span
lang=EN-US> MAXHOSTNAMELEN</span>个字</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>符，则把最后一个字符改成<span
lang=EN-US>NULL</span>字符。即<span lang=EN-US>thisname.nodename[min(i,MAXHOSTNAMELEN)]
= 0</span>。</p>

<p class=a><u><span lang=EN-US style='color:blue'>369</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (<u><span
style='color:blue'>thisname</span></u>.nodename[i]) {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>370</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>thisname</span></u>.nodename[i&gt;<u><span
style='color:blue'>MAXHOSTNAMELEN</span></u> ? <u><span style='color:blue'>MAXHOSTNAMELEN</span></u>
: i] = 0;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>371</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>372</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>373</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>374</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>取当前进程指定资源的界限值。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>进程的任务结构中定义有一个数组<span
lang=EN-US>rlim[RLIM_NLIMITS]</span>，用于控制进程使用系统资源的界限。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>数组每个项是一个<span
lang=EN-US>rlimit </span>结构，其中包含两个字段。 一个说明进程对指定资源的当前限制</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>界限（<span lang=EN-US>soft
limit</span>，即软限制），另一个说明系统对指定资源的最大限制界限（<span lang=EN-US>hard limit</span>，</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>即硬限制）。<span
lang=EN-US> rlim[] </span>数组的每一项对应系统对当前进程一种资源的界限信息。<span lang=EN-US>Linux 0.12</span></p>

<p class=a><span lang=EN-US>&nbsp; &nbsp;&nbsp;// </span>系统共对<span lang=EN-US>6</span>种资源规定了界限，即<span
lang=EN-US>RLIM_NLIMITS=6</span>。请参考头文件<span lang=EN-US>include/sys/resource.h</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>中第<span lang=EN-US>41 —
46</span>行的说明。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>参数<span lang=EN-US>
resource </span>指定我们咨询的资源名称，实际上它是任务结构中<span lang=EN-US>rlim[]</span>数组的索引项值。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>参数<span lang=EN-US>rlim</span>是指向<span
lang=EN-US>rlimit</span>结构的用户缓冲区指针，用于存放取得的资源界限信息。</p>

<p class=a><u><span lang=EN-US style='color:blue'>375</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_getrlimit</span></u>(int
resource, struct <u><span style='color:blue'>rlimit</span></u> *rlim)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>376</span></u><span
lang=EN-US> {</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>所咨询的资源<span
lang=EN-US>resource</span>实际上是进程任务结构中<span lang=EN-US>rlim[]</span>数组的索引项值。该索引值当然不能</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>大于数组的最大项数<span
lang=EN-US> RLIM_NLIMITS</span>。在验证过<span lang=EN-US> rlim </span>指针所指用户缓冲足够以后，这里就把</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>参数指定的资源<span
lang=EN-US>resource</span>结构信息复制到用户缓冲中，并返回<span lang=EN-US>0</span>。</p>

<p class=a><u><span lang=EN-US style='color:blue'>377</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (resource &gt;= <u><span
style='color:blue'>RLIM_NLIMITS</span></u>)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>378</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>EINVAL</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>379</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <u><span
style='color:blue'>verify_area</span></u>(rlim,sizeof *rlim);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>380</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <u><span
style='color:blue'>put_fs_long</span></u>(<u><span style='color:blue'>current</span></u>-&gt;rlim[resource].rlim_cur,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// </span>当前（软）限制值。</p>

<p class=a><u><span lang=EN-US style='color:blue'>381</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
(unsigned long *) rlim);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>382</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <u><span
style='color:blue'>put_fs_long</span></u>(<u><span style='color:blue'>current</span></u>-&gt;rlim[resource].rlim_max,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// </span>系统（硬）限制值。</p>

<p class=a><u><span lang=EN-US style='color:blue'>383</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
((unsigned long *) rlim)+1);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>384</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return
0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>385</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>386</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>设置当前进程指定资源的界限值。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>参数<span lang=EN-US>
resource </span>指定我们设置界限的资源名称，实际上它是任务结构中<span lang=EN-US>rlim[]</span>数组的索引</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>项值。参数<span lang=EN-US>rlim</span>是指向<span
lang=EN-US>rlimit</span>结构的用户缓冲区指针，用于内核读取新的资源界限信息。</p>

<p class=a><u><span lang=EN-US style='color:blue'>387</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_setrlimit</span></u>(int
resource, struct <u><span style='color:blue'>rlimit</span></u> *rlim)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>388</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>389</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct <u><span
style='color:blue'>rlimit</span></u> new, *old;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>390</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>首先判断参数<span
lang=EN-US>resource</span>（任务结构<span lang=EN-US>rlim[]</span>项索引值）有效性。然后先让<span
lang=EN-US>rlimit</span>结构指针</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // old</span>指向指进程任务结构中指定资源的当前<span
lang=EN-US>rlimit</span>结构信息。接着把用户提供的资源界限</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>信息复制到临时<span
lang=EN-US>rlimit</span>结构<span lang=EN-US>new</span>中。此时如果判断出<span lang=EN-US>new</span>结构中的软界限值或硬界限值</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>大于进程该资源原硬界限值，并且当前不是超级用户的话，就返回许可错。否则表示<span
lang=EN-US>new</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>中信息合理或者进程是超级用户进程，则修改原进程指定资源信息等于<span
lang=EN-US>new</span>结构中的信息，</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>并成功返回<span lang=EN-US>0</span>。</p>

<p class=a><u><span lang=EN-US style='color:blue'>391</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (resource &gt;= <u><span
style='color:blue'>RLIM_NLIMITS</span></u>)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>392</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>EINVAL</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>393</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; old = <u><span
style='color:blue'>current</span></u>-&gt;rlim + resource;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// </span>即<span lang=EN-US>old = current-&gt;rlim[resource]</span>。</p>

<p class=a><u><span lang=EN-US style='color:blue'>394</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new.rlim_cur = <u><span
style='color:blue'>get_fs_long</span></u>((unsigned long *) rlim);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>395</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new.rlim_max = <u><span
style='color:blue'>get_fs_long</span></u>(((unsigned long *) rlim)+1);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>396</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (((new.rlim_cur
&gt; old-&gt;rlim_max) ||</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>397</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
(new.rlim_max &gt; old-&gt;rlim_max)) &amp;&amp;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>398</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
!<u><span style='color:blue'>suser</span></u>())</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>399</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>EPERM</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>400</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *old = new;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>401</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>402</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>403</span></u><span
lang=EN-US> </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>404</span></u><span
lang=EN-US> <b><i>/*</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>405</span></u><span
lang=EN-US> <b><i>&nbsp;* It would make sense to put struct rusuage in the
task_struct,</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>406</span></u><span
lang=EN-US> <b><i>&nbsp;* except that would make the task_struct be *really
big*.&nbsp; After</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>407</span></u><span
lang=EN-US> <b><i>&nbsp;* task_struct gets moved into malloc'ed memory, it
would</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>408</span></u><span
lang=EN-US> <b><i>&nbsp;* make sense to do this.&nbsp; It will make moving the
rest of the information</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>409</span></u><span
lang=EN-US> <b><i>&nbsp;* a lot simpler!&nbsp; (Which we're not doing right now
because we're not</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>410</span></u><span
lang=EN-US> <b><i>&nbsp;* measuring them yet).</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>411</span></u><span
lang=EN-US> <b><i>&nbsp;*/</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; /* </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>把<span
lang=EN-US>rusuage</span>结构放进任务结构<span lang=EN-US>task struct</span>中是恰当的，除非它会使任务</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>结构长度变得非常大。在把任务结构移入内核<span
lang=EN-US>malloc</span>分配的内存中之后，</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>这样做即使任务结构很大也没问题了。这将使得其余信息的移动变得非常</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>方便！（我们还没有这样做，因为我们还没有测试过它们的大小）。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; */</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>获取指定进程的资源利用信息。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>本系统调用提供当前进程或其已终止的和等待着的子进程资源使用情况。如果参数<span
lang=EN-US>who</span>等于</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // RUSAGE_SELF</span>，则返回当前进程的资源利用信息。如果指定进程<span
lang=EN-US>who </span>是<span lang=EN-US> RUSAGE_CHILDREN</span>，</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>则返回当前进程的已终止和等待着的子进程资源利用信息。
符号常数<span lang=EN-US>RUSAGE_SELF </span>和</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // RUSAGE_CHILDREN </span>以及<span
lang=EN-US> rusage</span>结构都定义在<span lang=EN-US> include/sys/resource.h</span>头文件中。</p>

<p class=a><u><span lang=EN-US style='color:blue'>412</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_getrusage</span></u>(int who,
struct <u><span style='color:blue'>rusage</span></u> *ru)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>413</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>414</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct <u><span
style='color:blue'>rusage</span></u> r;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>415</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unsigned
long&nbsp;&nbsp; *lp, *lpend, *dest;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>416</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>首先判断参数指定进程的有效性。如果<span
lang=EN-US>who</span>既不是<span lang=EN-US>RUSAGE_SELF</span>（指定当前进程），也不是</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // RUSAGE_CHILDREN </span>（指定子进程），则以无效参数码返回。否则在验证了指针<span
lang=EN-US>ru </span>指定的用</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>户缓冲区域后，把临时<span
lang=EN-US> rusage</span>结构区域<span lang=EN-US>r</span>清零。</p>

<p class=a><u><span lang=EN-US style='color:blue'>417</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (who != <u><span
style='color:blue'>RUSAGE_SELF</span></u> &amp;&amp; who != <u><span
style='color:blue'>RUSAGE_CHILDREN</span></u>)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>418</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>EINVAL</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>419</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <u><span
style='color:blue'>verify_area</span></u>(ru, sizeof *ru);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>420</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <u><span
style='color:blue'>memset</span></u>((char *) &amp;r, 0, sizeof(r));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// </span>在<span lang=EN-US>include/strings.h</span>文件最后。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>若参数<span lang=EN-US>who
</span>是<span lang=EN-US>RUSAGE_SELF</span>，则复制当前进程资源利用信息到<span lang=EN-US>r</span>结构中。若指定进程<span
lang=EN-US>who</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>是<span lang=EN-US>RUSAGE_CHILDREN</span>，
则复制当前进程的已终止和等待着的子进程资源利用信息到临时</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // rusuage</span>结构<span
lang=EN-US>r</span>中。宏<span lang=EN-US>CT_TO_SECS </span>和<span lang=EN-US>CT_TO_USECS</span>用于把系统当前嘀嗒数转换成用秒值</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>加微秒值表示。它们定义在<span
lang=EN-US> include/linux/sched.h </span>文件中。<span lang=EN-US> jiffies_offset</span>是系统</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>嘀嗒数误差调整数。</p>

<p class=a><u><span lang=EN-US style='color:blue'>421</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (who == <u><span
style='color:blue'>RUSAGE_SELF</span></u>) {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>422</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
r.ru_utime.tv_sec = <u><span style='color:blue'>CT_TO_SECS</span></u>(<u><span
style='color:blue'>current</span></u>-&gt;<u><span style='color:blue'>utime</span></u>);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>423</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
r.ru_utime.tv_usec = <u><span style='color:blue'>CT_TO_USECS</span></u>(<u><span
style='color:blue'>current</span></u>-&gt;<u><span style='color:blue'>utime</span></u>);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>424</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
r.ru_stime.tv_sec = <u><span style='color:blue'>CT_TO_SECS</span></u>(<u><span
style='color:blue'>current</span></u>-&gt;<u><span style='color:blue'>stime</span></u>);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>425</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
r.ru_stime.tv_usec = <u><span style='color:blue'>CT_TO_USECS</span></u>(<u><span
style='color:blue'>current</span></u>-&gt;<u><span style='color:blue'>stime</span></u>);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>426</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>427</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;r.ru_utime.tv_sec = <u><span style='color:blue'>CT_TO_SECS</span></u>(<u><span
style='color:blue'>current</span></u>-&gt;cutime);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>428</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
r.ru_utime.tv_usec = <u><span style='color:blue'>CT_TO_USECS</span></u>(<u><span
style='color:blue'>current</span></u>-&gt;cutime);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>429</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
r.ru_stime.tv_sec = <u><span style='color:blue'>CT_TO_SECS</span></u>(<u><span
style='color:blue'>current</span></u>-&gt;cstime);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>430</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
r.ru_stime.tv_usec = <u><span style='color:blue'>CT_TO_USECS</span></u>(<u><span
style='color:blue'>current</span></u>-&gt;cstime);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>431</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>然后让<span lang=EN-US>lp</span>指针指向<span
lang=EN-US>r</span>结构，<span lang=EN-US>lpend</span>指向<span lang=EN-US>r</span>结构末尾处，而<span
lang=EN-US>dest</span>指针指向用户空间中的<span lang=EN-US>ru</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>结构。最后把<span
lang=EN-US>r</span>中信息复制到用户空间<span lang=EN-US>ru</span>结构中，并返回<span lang=EN-US>0</span>。</p>

<p class=a><u><span lang=EN-US style='color:blue'>432</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lp = (unsigned long
*) &amp;r;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>433</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lpend = (unsigned
long *) (&amp;r+1);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>434</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dest = (unsigned
long *) ru;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>435</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (; lp &lt;
lpend; lp++, dest++) </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>436</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>put_fs_long</span></u>(*lp, dest);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>437</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return(0);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>438</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>439</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>取得系统当前时间，并用指定格式返回。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // timeval</span>结构和<span
lang=EN-US>timezone</span>结构都定义在<span lang=EN-US>include/sys/time.h</span>文件中。<span
lang=EN-US>timeval</span>结构含有秒</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>和微秒（<span lang=EN-US>tv_sec</span>和<span
lang=EN-US>tv_usec</span>）两个字段。<span lang=EN-US>timezone</span>结构含有本地距格林尼治标准时间以西</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>的分钟数（<span lang=EN-US>tz_minuteswest</span>）和夏令时间调整类型（<span
lang=EN-US>tz_dsttime</span>）两个字段。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>（<span lang=EN-US>dst
-- Daylight Savings Time</span>）</p>

<p class=a><u><span lang=EN-US style='color:blue'>440</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_gettimeofday</span></u>(struct <u><span
style='color:blue'>timeval</span></u> *tv, struct <u><span style='color:blue'>timezone</span></u>
*tz)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>441</span></u><span
lang=EN-US> {</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>如果参数给定的<span
lang=EN-US>timeval</span>结构指针不空，则在该结构中返回当前时间（秒值和微秒值）；</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>如果参数给定的用户数据空间中<span
lang=EN-US> timezone</span>结构的指针不空，则也返回该结构的信息。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>程序中<span lang=EN-US>startup_time</span>是系统开机时间（秒值）。
宏<span lang=EN-US>CT_TO_SECS</span>和<span lang=EN-US>CT_TO_USECS</span>用于</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>把系统当前嘀嗒数转换成用秒值加微秒值表示。它们定义在<span
lang=EN-US>include/linux/sched.h</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>文件中。<span lang=EN-US>jiffies_offset</span>是系统嘀嗒数误差调整数。</p>

<p class=a><u><span lang=EN-US style='color:blue'>442</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (tv) {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>443</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>verify_area</span></u>(tv, sizeof *tv);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>444</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>put_fs_long</span></u>(<u><span style='color:blue'>startup_time</span></u>
+ <u><span style='color:blue'>CT_TO_SECS</span></u>(<u><span style='color:blue'>jiffies</span></u>+<u><span
style='color:blue'>jiffies_offset</span></u>),</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>445</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
(unsigned long *) tv);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>446</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>put_fs_long</span></u>(<u><span style='color:blue'>CT_TO_USECS</span></u>(<u><span
style='color:blue'>jiffies</span></u>+<u><span style='color:blue'>jiffies_offset</span></u>),
</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>447</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;((unsigned long *) tv)+1);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>448</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>449</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (tz) {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>450</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>verify_area</span></u>(tz, sizeof *tz);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>451</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>put_fs_long</span></u>(<u><span style='color:blue'>sys_tz</span></u>.tz_minuteswest,
(unsigned long *) tz);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>452</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>put_fs_long</span></u>(<u><span style='color:blue'>sys_tz</span></u>.tz_dsttime,
((unsigned long *) tz)+1);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>453</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>454</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>455</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>456</span></u><span
lang=EN-US> </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>457</span></u><span
lang=EN-US> <b><i>/*</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>458</span></u><span
lang=EN-US> <b><i>&nbsp;* The first time we set the timezone, we will warp the
clock so that</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>459</span></u><span
lang=EN-US> <b><i>&nbsp;* it is ticking GMT time instead of local time.&nbsp;
Presumably, </i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>460</span></u><span
lang=EN-US> <b><i>&nbsp;* if someone is setting the timezone then we are
running in an</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>461</span></u><span
lang=EN-US> <b><i>&nbsp;* environment where the programs understand about
timezones.</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>462</span></u><span
lang=EN-US> <b><i>&nbsp;* This should be done at boot time in the /etc/rc
script, as</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>463</span></u><span
lang=EN-US> <b><i>&nbsp;* soon as possible, so that the clock can be set
right.&nbsp; Otherwise,</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>464</span></u><span
lang=EN-US> <b><i>&nbsp;* various programs will get confused when the clock
gets warped.</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>465</span></u><span
lang=EN-US> <b><i>&nbsp;*/</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; /* </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>在第<span
lang=EN-US>1</span>次设置时区（<span lang=EN-US>timezone</span>）时，我们会改变时钟值以让系统使用格林</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>尼治标准时间（<span
lang=EN-US>GMT</span>）运行，而非使用本地时间。 推测起来说，如果某人</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>设置了时区时间，那么我们就运行在程序知晓时区时间的环境中。设置时</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>区操作应该在系统启动阶段，尽快地在<span
lang=EN-US>/etc/rc</span>脚本程序中进行。这样时</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>钟就可以设置正确。 否则的话，若我们以后才设置时区而导致时钟时间</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>改变，可能会让一些程序的运行出现问题。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; */</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>设置系统当前时间。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>参数<span lang=EN-US>tv</span>是指向用户数据区中<span
lang=EN-US>timeval</span>结构信息的指针。参数<span lang=EN-US>tz</span>是用户数据区中<span
lang=EN-US>timezone</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>结构的指针。该操作需要超级用户权限。如果两者皆为空，则什么也不做，函数返回<span
lang=EN-US>0</span>。</p>

<p class=a><u><span lang=EN-US style='color:blue'>466</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_settimeofday</span></u>(struct <u><span
style='color:blue'>timeval</span></u> *tv, struct <u><span style='color:blue'>timezone</span></u>
*tz)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>467</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>468</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static
int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; firsttime = 1;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>469</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
void&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <u><span
style='color:blue'>adjust_clock</span></u>();</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>470</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>设置系统当前时间需要超级用户权限。如果<span
lang=EN-US>tz</span>指针不空，则设置系统时区信息。即复制用户</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // timezone</span>结构信息到系统中的<span
lang=EN-US> sys_tz</span>结构中（见第<span lang=EN-US>24</span>行）。如果是第<span
lang=EN-US>1</span>次调用本系统调用</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>并且参数<span lang=EN-US>tv</span>指针不空，则调整系统时钟值。</p>

<p class=a><u><span lang=EN-US style='color:blue'>471</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!<u><span
style='color:blue'>suser</span></u>())</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>472</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return -<u><span style='color:blue'>EPERM</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>473</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (tz) {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>474</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>sys_tz</span></u>.tz_minuteswest = <u><span
style='color:blue'>get_fs_long</span></u>((unsigned long *) tz);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>475</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>sys_tz</span></u>.tz_dsttime = <u><span
style='color:blue'>get_fs_long</span></u>(((unsigned long *) tz)+1);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>476</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if (firsttime) {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>477</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
firsttime = 0;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>478</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if (!tv)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>479</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>adjust_clock</span></u>();</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>480</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>481</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>如果参数的<span lang=EN-US>timeval</span>结构指针<span
lang=EN-US>tv</span>不空，则用该结构信息设置系统时钟。首先从<span lang=EN-US>tv</span>所指处</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>获取以秒值（<span
lang=EN-US>sec</span>）加微秒值（<span lang=EN-US>usec</span>）表示的系统时间，然后用秒值修改系统开机时间全局</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>变量<span lang=EN-US>startup_time</span>值，并用微秒值设置系统嘀嗒误差值<span
lang=EN-US>jiffies_offset</span>。</p>

<p class=a><u><span lang=EN-US style='color:blue'>482</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (tv) {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>483</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
int sec, usec;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>484</span></u><span
lang=EN-US> </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>485</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
sec = <u><span style='color:blue'>get_fs_long</span></u>((unsigned long *)tv);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>486</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
usec = <u><span style='color:blue'>get_fs_long</span></u>(((unsigned long *)tv)+1);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>487</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>488</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>startup_time</span></u> = sec - <u><span
style='color:blue'>jiffies</span></u>/<u><span style='color:blue'>HZ</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>489</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u><span style='color:blue'>jiffies_offset</span></u> = usec * <u><span
style='color:blue'>HZ</span></u> / 1000000 - <u><span style='color:blue'>jiffies</span></u>%<u><span
style='color:blue'>HZ</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>490</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>491</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>492</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>493</span></u><span
lang=EN-US> </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>494</span></u><span
lang=EN-US> <b><i>/*</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>495</span></u><span
lang=EN-US> <b><i>&nbsp;* Adjust the time obtained from the CMOS to be GMT time
instead of</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>496</span></u><span
lang=EN-US> <b><i>&nbsp;* local time.</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>497</span></u><span
lang=EN-US> <b><i>&nbsp;* </i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>498</span></u><span
lang=EN-US> <b><i>&nbsp;* This is ugly, but preferable to the
alternatives.&nbsp; Otherwise we</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>499</span></u><span
lang=EN-US> <b><i>&nbsp;* would either need to write a program to do it in
/etc/rc (and risk</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>500</span></u><span
lang=EN-US> <b><i>&nbsp;* confusion if the program gets run more than once; it
would also be </i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>501</span></u><span
lang=EN-US> <b><i>&nbsp;* hard to make the program warp the clock precisely n
hours)&nbsp; or</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>502</span></u><span
lang=EN-US> <b><i>&nbsp;* compile in the timezone information into the
kernel.&nbsp; Bad, bad....</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>503</span></u><span
lang=EN-US> <b><i>&nbsp;*</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>504</span></u><span
lang=EN-US> <b><i>&nbsp;* XXX Currently does not adjust for daylight savings
time.&nbsp; May not</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>505</span></u><span
lang=EN-US> <b><i>&nbsp;* need to do anything, depending on how smart (dumb?)
the BIOS</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>506</span></u><span
lang=EN-US> <b><i>&nbsp;* is.&nbsp; Blast it all.... the best thing to do not
depend on the CMOS</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>507</span></u><span
lang=EN-US> <b><i>&nbsp;* clock at all, but get the time via NTP or timed if
you're on a </i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>508</span></u><span
lang=EN-US> <b><i>&nbsp;*
network....&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
- TYT, 1/1/92</i></b></span></p>

<p class=a><u><span lang=EN-US style='color:blue'>509</span></u><span
lang=EN-US> <b><i>&nbsp;*/</i></b></span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; /*</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>把从<span
lang=EN-US>CMOS</span>中读取的时间值调整为<span lang=EN-US>GMT</span>时间值保存，而非本地时间值。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; *</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>这里的做法很蹩脚，但要比其他方法好。否则我们就需要写一个程序并让它</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>在<span
lang=EN-US>/etc/rc</span>中运行来做这件事（并且冒着该程序可能会被多次执行而带来的</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>问题。 而且这样做也很难让程序把时钟精确地调整<span
lang=EN-US>n</span>小时） 或者把时区信</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>息编译进内核中。当然这样做就非常、非常差劲了<span
lang=EN-US>...</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>目前下面函数（<span
lang=EN-US>XXX</span>）的调整操作并没有考虑到夏令时问题。依据<span lang=EN-US>BIOS</span>有多</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>么智能（愚蠢？）也许根本就不用考虑这方面。当然，最好的做法是完全不</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>依赖于<span
lang=EN-US>CMOS</span>时钟，而是让系统通过<span lang=EN-US>NTP</span>（网络时钟协议）或者<span
lang=EN-US>timed</span>（时间</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; * </span>服务器）获得时间，如果机器联上网的话<span
lang=EN-US>...</span>。<span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
- TYT</span>，<span
 lang=EN-US>1/1/92</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp; */</span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>把系统启动时间调整为以<span
lang=EN-US>GMT</span>为标准的时间。</p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // startup_time</span>是秒值，因此这里需要把时区分钟值乘上<span
lang=EN-US>60</span>。</p>

<p class=a><u><span lang=EN-US style='color:blue'>510</span></u><span
lang=EN-US> void <u><span style='color:blue'>adjust_clock</span></u>()</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>511</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>512</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <u><span
style='color:blue'>startup_time</span></u> += <u><span style='color:blue'>sys_tz</span></u>.tz_minuteswest*60;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>513</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>514</span></u><span
lang=EN-US> </span></p>

<p class=a><span lang=EN-US>&nbsp;&nbsp;&nbsp; // </span>设置当前进程创建文件属性屏蔽码为<span
lang=EN-US>mask &amp; 0777</span>。并返回原屏蔽码。</p>

<p class=a><u><span lang=EN-US style='color:blue'>515</span></u><span
lang=EN-US> int <u><span style='color:blue'>sys_umask</span></u>(int mask)</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>516</span></u><span
lang=EN-US> {</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>517</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int old = <u><span
style='color:blue'>current</span></u>-&gt;<u><span style='color:blue'>umask</span></u>;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>518</span></u><span
lang=EN-US> </span></p>

<p class=a><u><span lang=EN-US style='color:blue'>519</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <u><span
style='color:blue'>current</span></u>-&gt;<u><span style='color:blue'>umask</span></u>
= mask &amp; 0777;</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>520</span></u><span
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return (old);</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>521</span></u><span
lang=EN-US> }</span></p>

<p class=a><u><span lang=EN-US style='color:blue'>522</span></u><span
lang=EN-US> </span></p>

<div class=a align=center style='text-align:center'><span lang=EN-US>

<hr size=4 width="100%" align=center>

</span></div>

<p class=MsoNormal><span lang=EN-US>&nbsp;</span></p>

</div>

</body>

</html>
